Finished Loading of ng-include in angular js

后端 未结 6 531
春和景丽
春和景丽 2020-12-13 02:28

What is the best way to detect the end of html loading by ng–include? I want to write some code that runs when it has finished loading.

6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-13 02:32

    There are two ways to detect when ng-include finished loading, depending on your need:

    1) via onload attribute - for inline expressions. Ex:

    2) via an event $includeContentLoaded that ng-include emits - for app-wide handling. Ex:

    app.run(function($rootScope){
      $rootScope.$on("$includeContentLoaded", function(event, templateName){
         //...
      });
    });
    

    when it finishes loading the content

提交回复
热议问题