The issue arises from calling Directive1 within the same Directive1 using ng-repeat. Although directive11 has a value in scope, when calling the nested directive with a new value, it appears to retain the initial value.
I attempted to invoke the same directive inside an ng-repeat of the directive
In the HTML code:
<accordion close-others="true">
<node function="functionCtrller(item)"
ng-repeat="item in list"
ng-model="item">
</node>
</accordion>
Within my directive definition:
myApp.directive('node', function($compile) {
return {
restrict : 'E',
terminal : true,
scope : {
node : '=ngModel',
function: '&function'
},
link : function($scope, $element) {
if (angular.isArray($scope.node.children) && $scope.node.children.length > 0) {
$element.append('<accordion close-others="true"><node function="function(item)" ng-repeat="item in node.children" ng-model="item"></node></accordion>');
}else{
//....
}
$compile($element.contents())($scope);
} //end_link_directive
}; //end_return_directive
No errors are thrown, only that the subsequent invocation of the function fails to capture the new item from the ng-repeat.