2
我想动态生成一个输入列表,并使用AngularJS + jQuery将它们的值绑定到模型的数组属性。AngularJS动态输入值绑定到数组模型
...
<section ng-controller="MyController">
<button ng-click="addInput">Add new field</button>
<section class="input-group"></section>
</section>
...
$scope.model = {
'title': 'aaa',
'arr': []
};
$scope.instructionCount = 0;
$scope.addInput = function() {
$model.arr.push('');
$('.input-group').append(
'<input type="text"
ng-bind="$scope.model.arr[' + ++$scope.instructionCount + ']">
);
};
为什么不能正常工作?
我认为你正在呼吁与click事件错误的函数。 –
更新,谢谢。 – Crossfire