答案 0 :(得分:3)
您需要在调用item
&时传递increament
个对象decreament
功能
<强>标记强>
<li data-ng-repeat="item in data">
<span>
id:{{ item.id }}
<button ng-click="increment(item);">+</button>
age:{{ item.age }}
<button ng-click="decrement(item);">-</button>
<button data-ng-click="delItem(item)">X</button>
</span>
</li>
<强>代码强>
$scope.increment = function (item) {
if (item.age >= max) { return; }
item.age++;
};
$scope.decrement = function (item) {
if (item.age <= min) { return; }
item.age--;
};