首页 > angularjs 使用ng-hide的问题。

angularjs 使用ng-hide的问题。

<div class="原有的class" ng-hide=“{{item.amount}}=0” ng-repeat=“item in items track by $index”>
具体内容
</div>

item.amount就是商品的数量,点击 - 的时候会动态修改
这个图是具体要应用的场景,在点击 - 时,当等于0的时候需要隐藏掉这个div,现在的情况是 刷新页面或者跳转后再过来能隐藏掉,但是在点击 - 的时候不能立即隐藏。请问该怎么解决,因为是ng-repeat出来的列表,ng-hide不能直接传一个布尔值,请问还有什么方法能解决么?


用ng-hide="item.amount==0"

var app = angular.module('plunker', []);

app.controller('MainCtrl', function($scope) {
  $scope.name = 'World';
  $scope.items = [{amount:0}];
  
  $scope.minus = function(){
    --$scope.items[0].amount;
  }
});

  <body ng-controller="MainCtrl">
    <div ng-hide="item.amount==0" ng-repeat="item in items track by $index">
      {{item.amount}}
    </div>
    <button ng-click="minus()">-</button>
  </body>

http://plnkr.co/edit/7KeNE5BtMJvRmjrafcr0


ng-hide=“item.amount==0”
【热门文章】
【热门文章】