angularjs ng-repeat y ng-model no van bien con el textarea/de la etiqueta de entrada
-
21-12-2019 - |
Pregunta
Cuando puedo generar etiquetas input con ng-repeat y asignar ng-model dentro de personalizado directiva se invoca la directiva en cada golpe de tecla.
Este es el Demo
http://plnkr.co/edit/Oku8EH?p=preview
var app = angular.module('myApp', []);
app.controller('MyCtrl', function($scope) {
$scope.arr = ["1234567"];
});
app.directive('myDirective', function($compile, $timeout) {
var num=0;
return {
link: function(scope, el, attrs) {
console.log('this happens with every keyup event in textarea when ng-model is given as arr[$index], why?');
}
};
});
<body ng-app="myApp" ng-controller="MyCtrl">
arr[0] : {{arr[0]}} <br/>
<input my-directive ng-repeat="str in arr" ng-model="arr[$index]" />
</input>
</body>
Es extraño.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow