I'm learning things a little backwards because I hopped from jquery to angualrJs without truly learning javascript. I do know some javascript but I'm also very lost on how to implement it with my Angular Projects. My current dilemma is that I'm trying to use javascript in a controller to scroll left or right when a button is hovered over in my view.
My javascript function in my controller is as follows.
(function() {
'use strict';
angular
.module('bhamDesign')
.controller('GalleryController', GalleryController);
/** @ngInject */
function GalleryController($scope, $stateParams, $http) {
var vm = $scope;
$http.get('assets/json/galleries/' + $stateParams.mainId + '.json').success(function(data) {
vm.gallery = data;
});
vm.toggle = false;
vm.imageLightbox = function (image) {
vm.toggle=!vm.toggle;
vm.imageSingle = image;
};
vm.scrollLeft = function(){
getElementsByClassName('img-container').scrollLeft += 20;
};
vm.scrollRight = function(){
getElementsByClassName('img-container').scrollRight += 20;
};
}
})();
and it is called from the view like so.
<i id="scroll-left" ng-mouseover="scrollLeft()" class="fa fa-angle-left"></i>
<i id="scroll-right" ng-mouseover="scrollRight()" class="fa fa-angle-right"></i>
<div class="img-container">
<img ng-src="{{image}}" ng-repeat="image in gallery.images" ng-click="imageLightbox(image)">
</div>
I feel like I have to call the element from the DOM into my javascript function in order for it to work correctly but I'm a little lost about what I'm actually doing. Can someone help me connect the dots?