When I click on the up/down arrows, I am attempting to continuously increase/decrease a value using AngularJS $interval function. However, I keep encountering an error message that says "TypeError: $interval is not a function." Can someone please help me solve this issue? Here is the code snippet I have been working on:
$scope.onMouseDown = function (type) {
promise = $interval(function () {
if (type == 'Inc') {
$scope.increaseVal();
}
else if (type == 'Dec') {
$scope.decreaseVal();
}
}, 150);
};
$scope.stopInterval = function () {
$interval.cancel(promise);
};
<div><a href="javascript:;" class="arrow" data-spin="up"><i class="fa fa-caret-up" ng-mousedown="onMouseDown('Inc')" ng-mouseup="stopInterval()" ng-mouseleave="stopInterval()" ng-click="increaseVal()"></i></a>
<a href="javascript:;" class="arrow" data-spin="down"><i class="fa fa-caret-down" ng-mousedown="onMouseDown('Dec')"
ng-mouseup="stopInterval()" ng-mouseleave="stopInterval()" ng-click="decreaseVal()"></i></a>
</div>