angular.js - angularjs 使用ng-hide的问题。
问题描述
<p ng-hide=“{{item.amount}}=0” ng-repeat=“item in items track by $index”>具体内容</p>
item.amount就是商品的数量,点击 - 的时候会动态修改这个图是具体要应用的场景,在点击 - 时,当等于0的时候需要隐藏掉这个p,现在的情况是 刷新页面或者跳转后再过来能隐藏掉,但是在点击 - 的时候不能立即隐藏。请问该怎么解决,因为是ng-repeat出来的列表,ng-hide不能直接传一个布尔值,请问还有什么方法能解决么?
问题解答
回答1:用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'> <p ng-hide='item.amount==0' ng-repeat='item in items track by $index'> {{item.amount}} </p> <button ng-click='minus()'>-</button> </body>
http://plnkr.co/edit/7KeNE5BtMJvRmjrafcr0
回答2:ng-hide=“item.amount==0”
相关文章:
1. javascript - 百度坐标,返回目标附近有哪些坐标2. html5 - 只用CSS如何实现input框的宽度随框里输入的内容长短自动适应?3. javascript - 关于jsp中嵌入js代码的问题4. PHP类中的$this5. html - 急求,能否用flex或者高端点的CSS来布局这个图呢?不想用浮动或定位了6. java - 微信开发遇到一个 bug。。access_token 有关的7. Python操作sqlserver是异步的吗?8. python 正则表达式提取9. python - 这句是什么错误?10. angular.js - angularjs 百度统计怎么统计

网公网安备