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. css3 - 手机网页中用css写1px的描边,为什么需要加一句overflow:hidden才能真正显示1px?2. mysql - 一个表和多个表是多对多的关系,该怎么设计3. mysql新建字段时 timestamp NOT NULL DEFAULT ’0000-00-00 00:00:00’ 报错4. python - type函数问题5. php - 第三方支付平台在很短时间内多次异步通知,订单多次确认收款6. Mysql && Redis 并发问题7. javascript - 百度echarts series数据更新问题8. css3 - css before 中文乱码?9. javascript - node服务端渲染的困惑10. css - 求推荐几款好用的移动端页面布局调试工具呢?
