angularjs - Using $timeout within my app -
i'm using $timeout service , i'm wondering why 'mainctrl.date.raw' variable won't update every second. ideas?
angular.module('myapp', []) .controller('mainctrl', ['$timeout',function($timeout){ var mainctrl = this; mainctrl.date = {}; $timeout(function(){ mainctrl.date.raw = new date(); }, 1000); }]);
use $interval
instead, since $timeout
fire function once when timer finishes, , $interval
fire function when counter finishes, , start again counter, until clear it.
angular.module('myapp', []) .controller('mainctrl', ['$interval',function($interval){ var mainctrl = this; mainctrl.date = {}; $interval(function(){ mainctrl.date.raw = new date(); }, 1000); }]);
Comments
Post a Comment