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. nignx - docker內nginx 80端口被占用2. angular.js - angular內容過長展開收起效果3. docker容器呢SSH為什么連不通呢?4. css - chrome瀏覽器input記錄上次cookie信息后,有個黃色背景~如何去除!5. 關docker hub上有些鏡像的tag被標記““This image has vulnerabilities””6. docker網絡端口映射,沒有方便點的操作方法么?7. android clickablespan獲取選中內容8. debian - docker依賴的aufs-tools源碼哪里可以找到啊?9. docker images顯示的鏡像過多,狗眼被亮瞎了,怎么辦?10. docker綁定了nginx端口 外部訪問不到
