Iam new to angular framework.Here is my scenario where, I want to change my $scope.variable after a period of time so i used javascript setTimeout method.
$scope.variable = 'Previous';
setTimeout(function(){
$scope.variable='NEXT';
},3000);
This code doesn't work for me. I used $apply() to make this code work.
Later I came to know that angular itself has a $timeout service which does the same work.
$scope.variable = 'Previous';
$timeout(function () {
$scope.variable = 'NEXT';
}, 2000);
How can i compare performance of $timeout service with javascript setTimeout??
Why we should use $timeout instead of setTimeout??
Please give me some examples and reasons to use it, which shows the performance.
Thanks :)
$rootScope.$digest()makes the app freeze, it will freeze once more. It is as simple as that.