我有一個控制器和控制我循環
NG點擊=「minusOne($指數)」和NG點擊=「Plusone精選($指數)」,但如果我點擊第一個阻止其改變所有的迭代,但我想,如果我第一個塊單擊它應該首先塊僅上點擊的所有項目一起是在迭代工作 - angularjs
.controller('MainController', ['$scope', '$rootScope', function($scope, $rootScope) {
$scope.fine = [{
likes: 0,
dislikes: 0
}];
$scope.plusOne = function(index) {
$scope.fine[index].likes += 1 * 10;
};
$scope.minusOne = function(index) {
$scope.fine[index].dislikes += 1 * 10;
};
$scope.buildBreak = function(index) {
$scope.fine[index].likes += 1 * 50;
};
}])
的Html
上工作<div class="item item-body addfineinfo" ng-repeat="putfine in fine">
<a ng-click="plusOne($index)" class="button button-small button-dark">+ Fine</a>
<a ng-click="minusOne($index)" class="button button-small button-dark">- Fine</a>
<a ng-click="buildBreak($index)" class="button button-small button-assertive">BUILD BREAK</a>
<input name="message" readonly type="text" value="{{ putfine.likes - putfine.dislikes }}" placeholder="Suhr">
值應該來在這個領域,這也是互爲作用
似乎是什麼問題? - > http://plnkr.co/edit/49YpzoEZHjMUWGV2zSNb?p=preview – chris
我沒有看到有任何問題 – simon
同意w /克里斯...代碼似乎很好。在上面的示例中,只顯示數組中的一個項目。你如何在數組中放置多個項目?例如,如果數組填充了w /對同一對象的引用,則可能會出現您描述的問題。 –