angular.js - When is the onload of angularjs called back?
曾经蜡笔没有小新
曾经蜡笔没有小新 2017-05-15 17:05:29
0
1
629

I see it is written like this in the document, saying that this expression is executed after the new part is loaded, but when is this "loading"?
Expression to evaluate when a new partial is loaded.

For example, if I ng-include an html, I tested it and found that this callback must occur after the js code of the controller corresponding to the html is loaded, but it does not seem to be loaded after the html is rendered?

For example,

<ion-view>
    <p ng-include="'path/page.html'" onload="callback()"></p>    //page.html也有对应的Child controller
</ion-view>

The Father controller corresponding to this page is defined in:

   $scope.callback = funtion(){
        $('#apId').html();    //apId这个idp在page.html里面
   }

But you cannot get the apId content this way. You can get it if you delay for a while.

This seems to mean that onload does not call back after the content in ng-include is rendered. So how can I get a callback function after the page in ng-include is rendered?

曾经蜡笔没有小新
曾经蜡笔没有小新

reply all(1)
漂亮男人

I don’t quite understand it, if you want to load a page asynchronously and then execute something. Then I suggest you use the oc.lazyload component to implement asynchronous loading. For details, you can visit: https://oclazyload.readme.io/ to check it out.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template