您的位置:首頁技術文章
文章詳情頁

angular.js - angularjs 使用ng-hide的問題。

瀏覽:190日期:2024-10-10 08:08:50

問題描述

<p ng-hide=“{{item.amount}}=0” ng-repeat=“item in items track by $index”>具體內容</p>

item.amount就是商品的數量,點擊 - 的時候會動態修改這個圖是具體要應用的場景,在點擊 - 時,當等于0的時候需要隱藏掉這個p,現在的情況是 刷新頁面或者跳轉后再過來能隱藏掉,但是在點擊 - 的時候不能立即隱藏。請問該怎么解決,因為是ng-repeat出來的列表,ng-hide不能直接傳一個布爾值,請問還有什么方法能解決么?angular.js - angularjs 使用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”

相關文章:
国产综合久久一区二区三区