1 dakika sonra güncellenen bir Görünümüm var, bu görünümü terk etmeden önce zamanlayıcıyı durduruyorum ve her şey tamam. Geçerli görünüme döndükten sonra, zamanlayıcı tekrar başlatılmaz.
.controller('IndexCtrl', function($scope, $timeout, RestService) {
var updateN = 60*1000;
$scope.test = "View 1 - Update";
var update = function update() {
timer = $timeout(update, updateN);
/** make a http call to Rest API service and get data **/
RestService.getdata(function(data) {;
$scope.items = data.slice(0,2);
});
}();
/** Stop the timer before leave the view**/
$scope.$on('$ionicView.beforeLeave', function(){
$timeout.cancel(timer);
//alert("Before Leave");
});
/** Restart timer **/
$scope.$on('$ionicView.enter', function(){
$timeout(update, updateN);
//alert("Enter");
});
})
.controller('ViewCtrl2', function($scope) {
$scope.test = "View 2";
});
Sorun buydu. Her zaman açısal hizmeti [$ interval] kullanabilirsiniz (https://docs.angularjs.org/api/ng/service/$interval). – LeftyX