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ù)量,點(diǎn)擊 - 的時(shí)候會(huì)動(dòng)態(tài)修改這個(gè)圖是具體要應(yīng)用的場(chǎng)景,在點(diǎn)擊 - 時(shí),當(dāng)?shù)扔?的時(shí)候需要隱藏掉這個(gè)p,現(xiàn)在的情況是 刷新頁面或者跳轉(zhuǎn)后再過來能隱藏掉,但是在點(diǎn)擊 - 的時(shí)候不能立即隱藏。請(qǐng)問該怎么解決,因?yàn)槭莕g-repeat出來的列表,ng-hide不能直接傳一個(gè)布爾值,請(qǐng)問還有什么方法能解決么?
問題解答
回答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. mysql - 數(shù)據(jù)庫為什么需要鎖機(jī)制?2. 在MySQL中新增字段時(shí),報(bào)錯(cuò)??3. java - 安卓電視盒子取得了root權(quán)限但是不能安裝第三方應(yīng)用,請(qǐng)問該怎么辦?4. 老哥們求助啊5. javascript - vue-router怎么不能實(shí)現(xiàn)跳轉(zhuǎn)呢6. javascript - angularjs 中數(shù)組的修改問題7. npm鏡像站全新上線8. css3 - 請(qǐng)問一下在移動(dòng)端CSS布局布局中通常需要用到哪些元素,屬性?9. python - 模擬滑動(dòng)驗(yàn)證碼,有源碼,求解10. tp6表單令牌
