我有一个看起来像这样的按钮:

<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>


我如何赋予新的条件?

最佳答案

只需使用几个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>

10-05 20:43
查看更多