AngularJS: ng-include inside ng-repeat

by Kamal Kumawat

HTML

<script src="http://ci.angularjs.org/job/angular.js-vojta/217/artifact/build/pkg/0.10.7-b52d5233/angular-0.10.7-b52d5233.js"></script>
<a ng-click="tpl='tpl1.html'">tpl1.html</a> | <a ng-click="tpl='tpl2.html'">tpl2.html</a>
    
<h3>ng-include insise ng-repeat</h3>
<div ng-repeat="i in items">
    <ng-include src="tpl" onload="log('onload inside repeater')"></ng-include>
</div>

<h3>just ng-include</h3>
<div ng-controller="Controller">
  <ng-include src="tpl" onload="log('onload')"></ng-include>
</div>

<script type="text/ng-template" ng-controller="Controller1" id="tpl1.html">
  content 1
</script>
<script type="text/ng-template" ng-controller="Controller2" id="tpl2.html">
  content 2
</script>

JavaScript

function Controller($scope) {
    $scope.log = function(m) {
        alert(m);                
    };    
    $scope.items = [1, 2];
}