我有以下
HTML:
<i style="cursor:pointer" ng-click="addName()" class="icon-plus"></i> <i style="cursor:pointer" ng-click="delName({{$index}})" class="icon-remove"></i>
以及我控制器的$scope中的以下函数:
$scope.addName = function() { $scope.names.push($scope.newName); $scope.newName = ''; }; $scope.delName = function(i) { $scope.names.splice(i,1); };
错误在html中,不应事先评估ng-repeat $index:
原文链接:https://www.f2er.com/angularjs/141505.html这是有效的HTML:
<i style="cursor:pointer" ng-click="delName($index)" class="icon-remove"></i>