i tried to add a ng-repeat directive in a compile method of other directive but it is not work.
here's a demo: http://jsfiddle.net/yiooxir/mdptnqo5/1/
I expected that the 'field' directive be fruitful in the three fields (input) but this is not happening
here is my code:
html:
<div ng-app='myApp' ng-controller='testCtrl'>
{{object.var}}
<field value='object.var' plural></field>
</div>
js:
app.controller('testCtrl', function ($scope) {
$scope.object = {
var: [1, 2, 3]
}
});
app.directive('field', function($parse) {
return {
restrict: 'AE',
scope: {
value: '='
},
template: "<div><input type='text' ng-model='value'></div>",
link: function() {}
}
})
app.directive('plural', function($compile){
return {
priority: 1001,
compile: function(element, attr) {
element.attr({
'ng-repeat': 'i in object.var track by $index',
'value': 'object.var[$index]',
'button': ''
});
}
}
})