Make a mask layer in advance, display the mask when making a request (usually $http or $resource), and close the mask after promise resolves.
The logic is that simple, but because it occurs very frequently, you have to consider how to DRY it.
At the view level, if the mask is common to all applications, don’t write it in every route. Instead, consider writing it in the upper routing entry so that sub-routes can share it.
At the calling level, it is simple to save the mask state in $rootScope and use DI to retrieve it at any time; if it is more elaborate, just write a service to control it.
The mask itself can be encapsulated into a directive for easy reuse, but this thing is very simple, so it’s okay not to encapsulate it.
https://github.com/cgross/angular-busy/blob/master/README.md Use this module
Make a mask layer in advance, display the mask when making a request (usually $http or $resource), and close the mask after promise resolves.
The logic is that simple, but because it occurs very frequently, you have to consider how to DRY it.
At the view level, if the mask is common to all applications, don’t write it in every route. Instead, consider writing it in the upper routing entry so that sub-routes can share it.
At the calling level, it is simple to save the mask state in $rootScope and use DI to retrieve it at any time; if it is more elaborate, just write a service to control it.
The mask itself can be encapsulated into a directive for easy reuse, but this thing is very simple, so it’s okay not to encapsulate it.