gdfgdfg gdfgdfg - 1 year ago 89
AngularJS Question

ng-class not showing correct

I have form where when is $isvalidate = true, the button has class 'disable-reg-btn', like this:

ng-class="{{reg_form.$invalid ? 'disable-reg-btn' : ''}}"

, but when I see page in the browser and when the form is invalid I see in Dev tools in Chrome this:

<button ng-class="disable-reg-btn" ng-disabled="true" ......

and the class is not added.
Where is the error ?

I am using Angular 1.5.8.
Angular is added in the footer.
The button is within the div with ng-app and ng-controller attributes.

Answer Source

Use the Evaluated Expression:

ng-class="{'disable-reg-btn': reg_form.$invalid}"

Check this tutorial for more info.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download