angular.js - angularjs 使用ng-hide的問(wèn)題。
問(wèn)題描述
<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)在的情況是 刷新頁(yè)面或者跳轉(zhuǎn)后再過(guò)來(lái)能隱藏掉,但是在點(diǎn)擊 - 的時(shí)候不能立即隱藏。請(qǐng)問(wèn)該怎么解決,因?yàn)槭莕g-repeat出來(lái)的列表,ng-hide不能直接傳一個(gè)布爾值,請(qǐng)問(wèn)還有什么方法能解決么?
問(wèn)題解答
回答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. dockerfile - 我用docker build的時(shí)候出現(xiàn)下邊問(wèn)題 麻煩幫我看一下2. android-studio - Android studio導(dǎo)入老版本的2048項(xiàng)目報(bào)錯(cuò)3. TP6.0 Jump.php報(bào)錯(cuò)4. PhpStorm 輸入php按tab后生成的起始結(jié)束標(biāo)簽<php><php> 如何修改?5. 急急急!!!求大神解答網(wǎng)站評(píng)論問(wèn)題,有大神幫幫小弟嗎6. 冒昧問(wèn)一下,我這php代碼哪里出錯(cuò)了???7. php mail無(wú)法發(fā)送郵件8. PHP類屬性聲明?9. PHP 怎么api獲取json數(shù)據(jù)10. 為什么return不了數(shù)據(jù)給ajax
