Angular JS views not updating properly
As the docs explains:
$apply() is used to execute an expression in angular from outside of the angular framework. (For example from browser DOM events, setTimeout, XHR or third party libraries). Because we are calling into the angular framework we need to perform proper scope life-cycle of exception handling, executing watches.
So if you have a jQuery code like
$('#myDiv').on('click', function() { // do stuff $scope.$apply();});
You have to tell angular Js something has changed with $scope.$apply()
.
Here is a nice blog on why: http://www.yearofmoo.com/2012/10/more-angularjs-magic-to-supercharge-your-webapp.html#apply-digest-and-phase