I am using angularjs $interval function to increase/decrease a value continuously when I click on up/down arrows. But I am getting an error "TypeError: $interval is not a function" when I try to increase/decrease. How to solve this problem, thanks in advance. This is the code I have written so far:
$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>
increaseValanddecreaseValfunctions look like? @dev8080 Wouldn't it say cannot read property cancel of undefined if that was the case?