angular.js - angularjs 使用ng-hide的問題。
問題描述
<p ng-hide=“{{item.amount}}=0” ng-repeat=“item in items track by $index”>具體內(nèi)容</p>
item.amount就是商品的數(shù)量,點擊 - 的時候會動態(tài)修改這個圖是具體要應用的場景,在點擊 - 時,當?shù)扔?的時候需要隱藏掉這個p,現(xiàn)在的情況是 刷新頁面或者跳轉(zhuǎn)后再過來能隱藏掉,但是在點擊 - 的時候不能立即隱藏。請問該怎么解決,因為是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”
相關(guān)文章:
1. javascript - immutable配合react提升性能?2. javascript - sublime快鍵鍵問題3. 如何設(shè)置一個無限循環(huán)并打破它。(Java線程)4. 網(wǎng)頁爬蟲 - 如何使用使用java抓取信息并制作一個排名系統(tǒng)?5. python小白 自學看書遇到看不懂的地方6. DADB.class.php文件的代碼怎么寫7. php對mysql提取數(shù)據(jù)那種速度更快8. shell - mysql更新錯誤9. mysql - 在log日志中已知用戶的某一步操作,如何獲取其上一步操作?10. macos - 如何徹底刪除mac自帶的apache和php

網(wǎng)公網(wǎng)安備