admin管理员组文章数量:1285835
Thanks to this answer AngularJS app.run() documentation? i can see the order in which modules are ran by Angular, my question is:
if I have:
app.config(function () {
$routeProvider.when('/', {
....
resolve: {
// something to resolve
}
});
});
app.run(function () {
// something to run
});
Will run()
be executed before the routeProvider resolve:{}
is resolved?
Thanks to this answer AngularJS app.run() documentation? i can see the order in which modules are ran by Angular, my question is:
if I have:
app.config(function () {
$routeProvider.when('/', {
....
resolve: {
// something to resolve
}
});
});
app.run(function () {
// something to run
});
Will run()
be executed before the routeProvider resolve:{}
is resolved?
- 2 someone playing with -1 button like a kid – Filippo oretti Commented Jun 17, 2014 at 15:07
1 Answer
Reset to default 28At least in my experiments, yes the resolve is run after app.run
.
In this jsfiddle you can see the calling order I got was:
- app config
- app run
- directive setup
- directive compile
- app controller
- directive link
- ** Data resolve called **
- new route's controller
As you can see in the fiddle, I checked this by using a console.log
function as the value of a property of the object handed to resolve
:
resolve: {
data: function() {
console.log('Data resolve called');
}
}
You can use this same approach in your code to check when routeProvider
begins checking the dependencies.
本文标签: javascriptAngular jsresolve and run() order of executionStack Overflow
版权声明:本文标题:javascript - Angular js - resolve and run() order of execution - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738440030a2086904.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论