Finished Loading of ng-include in angular js

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

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

<div ng-include="'template.html'" onload="loaded = true"></div>

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

Leave a Comment