我有一个看起来像这样的按钮:
<button class="btn btn-default pull-right"
ng-disabled="subcategory.required2 == subcategory.completed2"
ng-click="open(subcategory)">Add Course <span class="glyphicon glyphicon-plus"></span>
</button>
只要满足条件,它就会被禁用。
但现在不是禁用我想隐藏它并显示如下警告:
<span class="alert alert-success">Requirement met</span>
我如何给出新条件?
答案 0 :(得分:1)
只需使用几个ng-if语句:
<button class="btn btn-default pull-right"
ng-if="subcategory.required2 != subcategory.completed2"
ng-click="open(subcategory)">Add Course <span class="glyphicon glyphicon-plus"></span>
<span ng-if="subcategory.required2 == subcategory.completed2" class="alert alert-success">Requirement met</span>
答案 1 :(得分:1)
您可以使用ng-show显示或隐藏按钮:
<button class="btn btn-default pull-right"
ng-show="subcategory.required2 != subcategory.completed2"
ng-click="open(subcategory)">Add Course <span class="glyphicon glyphicon-plus"></span>
</button>
然后在你的范围内添加另一个与逻辑反转的ng-show:
<span class="alert alert-success" ng-show="subcategory.required2 == subcategory.completed2">Requirement met</span>