LordZardeck
LordZardeck

Reputation: 8283

Angular binding for loading doesn't update the HTML

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

Answers (1)

zewa666
zewa666

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

Related Questions