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. php - 第三方支付平臺在很短時間內多次異步通知,訂單多次確認收款2. html5 - h5寫的app用的webview,用手機瀏覽器打開不顯示?3. css3 - css before 中文亂碼?4. Mysql && Redis 并發問題5. javascript - node服務端渲染的困惑6. javascript - 百度echarts series數據更新問題7. javascript - webpack --hot 熱重載無效的問題8. mysql新建字段時 timestamp NOT NULL DEFAULT ’0000-00-00 00:00:00’ 報錯9. mysql scripts提示 /usr/bin/perl: bad interpreter10. mysql - 一個表和多個表是多對多的關系,該怎么設計
