我想将循环索引传递给函数 Createprofile()。我想使用 Angular Controller 来执行此操作。
HTML
<li ng-repeat = "proteam in proteams | filter:filtText | filter:filtText1" ng-init="counter">
<p>{{proteam.description}}</p>
<div class="modal fade" id="collaborateForm" role="dialog" hidden="true" style="overflow: auto;">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content fade in">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">COLLABORATION FORM</h4>
</div>
<div class="modal-body" >
<!-- Collaborate FORM -->
<form ng-submit="createProfile(counter)" onkeypress="return event.keyCode != 13;">
<label>Enter team Name:</label>
<input type="text" class="form-control" id="teamName" required="required">
<button type="submit" class="btn btn-primary btn-xs" dismiss="modal" onClick="turnDivOff()">Collaborate</button>
</form>
</div>
</div>
</div>
</div>
</li>
最佳答案
试试看
<form ng-submit="createProfile($index)" onkeypress="return event.keyCode != 13;">
ng-repeat
需要一个数组,所以它有一个与之关联的索引
关于html - 如何在 ng-repeat 中使用 div 模态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36929198/