Angular Js Executing Function $timer Within $scope Receives Typeerror
Why is that when using $timeout in Angular JS that is inside function like the following, works fine. var mytimeout = $timeout(function(){ console.log('MyTimeout Executed'); },
Solution 1:
var mytimeout = $timeout($scope.myFunction(),2000);
This is your problem. Remove the ()
from the myFunction()
. You need to pass a function reference, not call the function and take the result (which in this case would be undefined
) and then pass that to $timeout.
Post a Comment for "Angular Js Executing Function $timer Within $scope Receives Typeerror"