Run Javascript AFTER Angular Has Finished Loading All Views

后端 未结 6 1347
抹茶落季
抹茶落季 2020-12-24 12:10

I am building a web application using Angular, and I am trying to find a way to wait until all of the data-ng-include elements have been evaluated and the inclu

6条回答
  •  鱼传尺愫
    2020-12-24 12:41

    I am certain that this is not the correct way to do it but....

    Putting the below function in my view controller, ran the function after the view had loaded in my application. I believe that the function is run in the next digest cycle following the view load (correct me here if wrong), so it is run once the page is formed.

    setTimeout(function(){
      //do this after view has loaded :)
      console.log('success!');
    }, 0);
    

    Its possible you could chain these together via callbacks and/or use an async parallel library to execute another function, after each of the views setTimeouts had returned.

提交回复
热议问题