在点击button发出请求后,由于网络或者数据较大的原因,页面中的angularJS双向绑定数据部分不显示,页面结构很难看,怎么能实现在所有的数据加载完成之前,弹出层覆盖掉原网页并且提示“正在加载”,等所有的数据加载完成之后,再显示带有完整数据的网页。
如下面的效果:
PHPz2017-05-15 16:58:25
https://github.com/cgross/angular-busy/blob/master/README.md Use this module
世界只因有你2017-05-15 16:58:25
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.