I want to use a websocket to get information once AngularJS is loaded, and then apply the new data to the template transformations. Is there a way to make AngularJS block while new data is being requested?
1 Answer
I typically use an approach where before making the async call, I set a $scope.loading = true; and in the promise's finally() callback, I set $scope.loading = false; With this flag set, it is very easy to use any of ng-switch/ng-show/ng-if to toggle visibility of elements in the template.
I have prepared a plunker demo showing this approach.
1 Comment
clearairturbulence
Thank you! This is exactly what I was looking for!
$scope.loading = true;flag in the controller and in the promise'sfinally()function, I set$scope.loading = false;. In my templates I would use something like:ng-if="!loading"orng-show="!loading"