Angular js bootstrap button disable

Angular js bootstrap button disable

I have the following angularjs app html file:

I would like to know if we can disable the Add course button whenever the condition required credits == completed credits is met. The controller is a regular json file with all the parameters in the subcategories.
Please help!


Solution 1:

Use the ng-disabled directive

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

Solution 2:

Just set the isDisabled variable in the controller based on the condition.

<button disabled="{{isDisabled}}">Disabled</button>


Related:  combine input-group and form-groups in bootstrap 3 horizontal form