Reputation: 8283
I am trying to show a loading indicator whenever a user clicks the save button. When the button is clicked, the state changes successfully, but reverting back the value of the loading
property on scope to the false state doesn't update the UI.
Is it something i'm doing wrong with scope properties, or is this a flaw with angular?
Here's my jsBin: http://jsbin.com/xafexorope/2/edit?html,output
Upvotes: 0
Views: 46
Reputation: 2603
The reason why it doesnt work is because Angular's internal dirty-checking loop is not fired. It's because you use a standard setTimeout. Instead of that, either manually call $scope.$apply() at the end of your setTimeout callback, or better, use the angular wrapper $timeout.
Here is your updated jsbin: http://jsbin.com/devuhovaxa/3/edit
Additionally here the docs for $timeout: https://docs.angularjs.org/api/ng/service/$timeout
Upvotes: 2