如何在app.run(function(){})处暂停整个应用程序的执行?
例如:
angular.module('frontendApp')
.run(function ($timeout) {
$timeout(function () {
next(); // While this function is not executed,
// the application must not download data and perform any task.
}, 1000);
});
如果您使用来引导您的应用程序,则无法进行ng-app="frontendApp"
。
但是,您可以通过手动引导来实现。而不是ng-app
在HTML中,在脚本中使用如下代码:
angular.element(document).ready(function() {
//Bootstrap the application after 3 seconds
setTimeout(function() {
angular.bootstrap(document, ['frontendApp']);
}, 3000);
});
还有一个延迟的引导过程,您可以在其中进行调用,angular.resumeBootstrap()
但是我认为这适用于测试。
此处提供更多信息:http : //docs.angularjs.org/guide/bootstrap
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句