I\'m trying to add an input element with ng-model inside a directive.
my code
the link function of my directive:
link: function (scope, element,
You are making directive more complicated than necessary by manually looping over arrays when you could use nested ng-repeat
in the directive template and let angular do the array loops:
angular.module("myApp", [])
.directive("myDirective", function () {
return {
restrict: 'EA',
replace: true,
scope: {
animals: '=animals'
},
template: ''+
'{{animal.id}}'+
''+
'
'+
''
}
});
DEMO: http://jsfiddle.net/Ajsy7/2/