javascript - AngularJS reevaluates bindings when I don't change anything in the scope -


i need update little digital 'clock' in angular app. i'm using following code in controller:

        $scope.time = new date();         var interval = $timeout(function updatetime() {             console.log("update time");             $scope.time = new date();             $scope.formattedtimevalue = wbutils.formattedtime($scope.time);             interval = $timeout(updatetime, 1000);         }, 1000); 

i display formattedtimevalue in little div in html using {{formattedtimevalue}} expression. have ng-repeat directive formatting data using filters. problem filters reevaluated every second. can't understand why. i've changed interval function following filters still reevaluated:

            var interval = $timeout(function updatetime() {               console.log("update time");               interval = $timeout(updatetime, 1000);             }, 1000); 

can please explain me why filter gets evaluated each second each object (unchanged) in ng-repeat. filter looks this:

module.filter('formatlogrecord', function () {     return function (log) {         console.log("filtering");         return "";     } }); 

the angular $timeout service includes making call $apply whole $rootscope ( https://github.com/angular/angular.js/blob/v1.2.0rc1/src/ng/timeout.js#l10 ), cause new digest , re-evaluate filters. if that's not want, use plain js settimeout instead , wrap bits dealing scope in $scope.$apply yourself.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

IIS->Tomcat Redirect: multiple worker with default -