동적으로 행을 추가하려면 다음 html 및 Angularjs 컨트롤러 코드가 있어야합니다.동적으로 생성 된 행을 제거하는 Angularjs
<form name="{{form.name}}"
ng-repeat="form in forms">
<h2>{{form.name}}</h2>
<div ng-repeat="(i,cont) in form.contacts">
<input type="text" class="xdTextBox" ng-model="cont.ac"/>
<input type="text" class="xdTextBox" ng-model="cont.a_number"/>
<input type="text" class="xdTextBox" ng-model="cont.p_id"/>
</div>
<button ng-click="submit(form)">Submit</button>
<button ng-click="addFields(form)">Add</button>
<hr>
</form>
컨트롤러 코드가 rowsis 추가
$scope.addFields = function (form) {
if (typeof form.contacts == 'undefined') {
form.contacts = [];
}
form.contacts.push({name:'', ac: '', a_number: '', p_id: '' });
}
내가 다음에하고 싶은 것은 모든 행 삭제 링크 나 버튼을 통해 내가 마우스가 나타나 하나를 클릭하면, 그것을 제거하는 경우 행을 추가 한 후입니다 그 행. 다음은 행 추가를위한 작업 플러 커입니다. http://plnkr.co/edit/9bUnd7t0PyMwykgi0VZR?p=preview 행에 마우스를 올려 놓고 제거 단추 또는 링크를 클릭하여 목록을 제거 할 수있는 방법을 알려주십시오. 감사
"(참고 : 당신은 단지 그것을 제거하는 것보다 더 복잡한 작업을 수행 할 필요가있는 경우는 연락처를 제거하기위한 스코프 내부의 기능을 할 수 있습니다 배열에서.) "당신이 강조하는 것이 좋다. – Kroltan
@ Sergey K brilliant, 내가 뭘 찾고 있었는지 – Jax