So is there any possibility to reach .then() only after $scope.counter reaches 5?
Here is JSFiddle
Somehow using Promise ruins my watcher - it applies only when window gets resized. So i would like to know if i could do it without Promises
<div ng-app="myApp">
<div ng-controller="myController">
<div>some{{message}}</div>
<div>counter: {{counter}} sec</div>
</div>
</div>
(function(){
var myApp = angular.module('myApp', []);
myApp.controller('myController', function($scope, $timeout){
//time
$scope.counter = 0;
$scope.message = "";
//timer callback
var timer = function() {
$scope.counter++;
if ($scope.counter > 5) {
return;
}
$timeout(timer, 1000);
}
$timeout(timer, 2000).then(function() {
$scope.message="body once told the world was gonna roll me";
});
});
})();