我需要知道ng-model的命名约定和ng-repeat内的ng-click。并且还需要知道如何在控制器中使用每个型号名称和ng-click功能。我给出了一个示例代码,向您展示我确切需要知道的内容。
<input name="" type="button" ng-click="incrementRoomCount()">
<div ng-repeat="student in studentList">
<div>Room <span>{{student.studentCount}}</span></div>
<div>
<input name="" type="button" ng-click="removeStudent()">
<input name="adult" type="text" ng-model="noOfStudents">
<input name="" type="button" class="roomPopupPlusBtn" ng-click="addStudent()">
</div>
<div ng-repeat="studentAge in studentList">
<div ng-show="studentAgeWrapper">
<select name="age">
<option ng-repeat="studentAge in ['20','21','22','23','24','25']">{{studentAge}</option>
</select>
</div>
</div>
</div>
由于
答案 0 :(得分:2)
以下小提琴演示了重复项目时如何调用函数。您也可以将id传递给remove函数。
<input value="Remove From Room" type="button" ng-click="removeStudent(student)"/>
</div>
$scope.removeStudent = function(student) {
angular.forEach($scope.studentList, function(checkStudent, index) {
if (checkStudent.id === student.id) {
$scope.studentList.splice(index,1);
}
});
};