admin管理员组文章数量:1312677
How to call a simple function, after all AngularJS views loaded successfully.
function hello() {
alert('All AngularJS works are done');
}
<!-- Below code is example about how I need a function for AngularJS loaded event -->
app.onAngularLoaded(function () { hello(); });
</script>
How to call a simple function, after all AngularJS views loaded successfully.
function hello() {
alert('All AngularJS works are done');
}
<!-- Below code is example about how I need a function for AngularJS loaded event -->
app.onAngularLoaded(function () { hello(); });
</script>
Share
Improve this question
edited Apr 27, 2015 at 17:06
αƞjiβ
3,25615 gold badges63 silver badges104 bronze badges
asked Apr 27, 2015 at 16:58
Vinoth KannanVinoth Kannan
2425 silver badges16 bronze badges
1
- Maybe it help: stackoverflow./questions/14968690/… – Wédney Yuri Commented Apr 27, 2015 at 17:13
3 Answers
Reset to default 4Try setting a timeout with a value of 0. That will happen after the current set of digest cycles.
$timeout(function(){...}, 0);
The problem w. what you are trying to tackle is that if you are using something like ng-include
or ui-router then you won't know when those are finished loading until they are requested and loaded. It's an on-demand scenario.
You may however be looking to do something post-bootstrapping of the angular process? If that is the case you need to do something like this on you main/root angular module:
angular.module('app', [ ... any ng-dependencies here ...])
.controller(...)
.controller(...)
.directive(...)
.service(...)
//then here is where you do your post-bootstrapping logic
.run( function(){
//code here
})
more info here - angular module docs
You can use directive to get it.
var homeApp = angular.module('home', ['ui.bootstrap', 'ngAnimate']);
homeApp
.directive("pagecontent",
function() {
return {
restrict: "E",
link: function() {
alert('All AngularJS works are done');
},
templateUrl: "template path",
}
本文标签: javascriptHow to call a function after AngularJS render all viewsStack Overflow
版权声明:本文标题:javascript - How to call a function after AngularJS render all views - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741911749a2404484.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论