當一個作用域($ filter.producers)中的一個或多個值設置爲true時,我想顯示一個符號(),而當所有值是錯誤的。我正在嘗試使用ng-show進行顯示,但我無法找到使其工作的方式。當某個值爲真時AngularJS ng-show
我的HTML是這樣的:
<div ng-app="myApp" ng-controller="Ctrl">
{{ctrlTest}}
<span ng-show="filter.producers == false">X</span>
<span ng-show="filter.producers != false"></span>
<hr/>
<div ng-repeat="elements in filter">
<div>
<li ng-repeat="(key,value) in filter.producers" ng-show="value">{{key}}
<a ng-click="filter.producers[key]=false"> X</a>
</li>
</div>
{{filter.producers}}
</div>
</div>
而且我的控制器:
angular.module('myApp', [])
.controller('Ctrl', function($scope) {
$scope.ctrlTest = "Filters";
$scope.filter = {
"producers": {
"Ford": true,
"Honda": true,
"Ferrari": true
}
}
});
這裏是一個工作plunker 提前感謝!
問題並不清楚。請提供更詳細的解釋。 – Roy
你忘了問這個問題! – svarog