Angular Spinning Directive Gets Instantiated After Controller Load
I have a controller. Here is the relevant part of the constructor function (what is the correct term for this function?): activate(); function activate() { $sc
Solution 1:
Trigger the activate function in $timeout.
functionactivate() {
$scope.$broadcast('ctrlLoadingStarted');
var promises = [getUsers()];
return$q.all(promises).then(function (eventArgs) {
$scope.$broadcast('ctrlLoadingFinished');
});
}
$timeout(activate)
With this the activate function will be called in next digest cycle.
More about Digest cycle Integration with the browser event loop
section at: https://docs.angularjs.org/guide/scope
Disclaimer: This is my understanding of how Javascript / browser works. It may not be correct.
Post a Comment for "Angular Spinning Directive Gets Instantiated After Controller Load"