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. thinkPHP5中獲取數據庫數據后默認選中下拉框的值,傳遞到后臺消失不見。有圖有代碼,希望有人幫忙2. 求救一下,用新版的phpstudy,數據庫過段時間會消失是什么情況?3. linux運維 - python遠程控制windows如何實現4. Python2中code.co_kwonlyargcount的等效寫法5. python - 如何對列表中的列表進行頻率統計?6. django - Python error: [Errno 99] Cannot assign requested address7. mysql數據庫做關聯一般用id還是用戶名8. javascript - 如何用最快的速度C#或Python開發一個桌面應用程序來訪問我的網站?9. python小白,關于函數問題10. python小白 關于類里面的方法獲取變量失敗的問題
