我有一个下拉菜单,如果选择了某些内容则关闭但如果未选择任何内容则保持打开状态。我试图这样做,以便在点击fa fa-caret-down箭头时它关闭,但它没有做到这一点。我该如何解决?以下是该部分的代码:
<label style="color:white;">How many players?</label>
<div ng-class="{true:'error-bron', false:'nonerror-bron'}[dropDownPeopleError===true]" class="dropdown" ng-click="test()">
<span>{{dropDownPeople}}</span>
<i class="fa fa-caret-down bron-caret" aria-hidden="true" ng-click="test(); $event.stopPropagation();"></i>
<div class="dropdown-content" ng-show="form.showDropDownPeople">
<a ng-repeat="item in people" ng-click="changePeople(item); $event.stopPropagation();">{{item}}</a>
</div>
</div>
这是我的控制器的一部分
$scope.test = function(){
$scope.form.showDropDownPeople = true;
}
答案 0 :(得分:0)
您可以使用ng-show
隐藏元素,其中元素仅显示标记内的表达式是否为真,即ng-show="showDropDownPeople"