angular, in directive, adding to the template an element with ng model
angularjs, angularjs-directive
Solution
Try
var a_input = angular.element($compile('<input type="text" ng-model="animals[0][' + i + '].name"/>')($scope))
elem_0.append(a_input);
Problem
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, attrs) { var elem_0 = angular.element(element.children()[0]); for (var i in scope.animals[0]) { elem_0.append(angular.element('<span>' + scope.animals[0][i].id + '</span>')); //this part doesn't work var a_input = angular.element('<input type="text">'); a_input.attr('ng-model', 'animals[0][' + i + '].name'); //end elem_0.append(a_input); } ``` it seems i need to call $compile() at the end, but have no idea how.