variable update problem in ng-repeat
HTML
<body>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.12/angular.js"></script>
<div ng-app="bugapp">
<div ng-controller="bugController">
<script type="text/ng-template" id="mytemplate.html">
My Template with item.ID = {{item.ID}}
</script>
<div ng-repeat="item in item.children">
item.ID : {{item.ID}}
<div ng-include="showVars(item.ID)"></div>
</div>
</div>
</div>
<br>Results of the calls :<br>
<div id="logs"></div>
<script>
var logs=document.getElementById('logs');
function logIt(msg){
var e=document.createElement('div');
e.innerHTML=msg;
logs.insertBefore(e,logs.firstChild);
}
angular.module('bugapp', [])
.controller('bugController', function ($scope) {
$scope.item = {
ID: 1,
children: {
1: {
ID: 11,
},
2: {
ID: 12,
}
},
};
$scope.showVars = function(itemID) {
logIt("calling getTemplate with $scope.item.ID = "+$scope.item.ID+" and itemID = "+itemID);
return 'mytemplate.html';
};
});
</script>
</body>