Infinite Loop When Trying To Make Angularjs Display A Promise
I'm facing an infinite loop when trying to make AngularJS display a promise, as explained in this article: http://markdalgleish.com/2013/06/using-promises-in-angularjs-views/. I fi
Solution 1:
You can't have anything with a side effect to scope in any angular expressions, otherwise the infinite loop will occurred.
It's by design to rerun all the expressions repeatedly until nothing has changed. So at the time the promise is resolved, the expressions will get evaluated again.
To avoid that, you could move the msg.get
call into the controller and store the promise as an another property in $scope
:
$scope.msg = {
get: function() {
return MessageHelper.get.apply(this, arguments);
}
};
$scope.resultMsg = $scope.msg.get("existing.message.code", "first param", "second param");
and use that in the template instead:
{{resultMsg}}
Hope this helps.
Post a Comment for "Infinite Loop When Trying To Make Angularjs Display A Promise"