Lets try with new example where we are changing the classes based on checkbox selection and hasError
class will apply on First Name textbox if hasError
variable is set to true with ng-model
directive.hasSuccess class will apply on Last Name textbox if hasSuccess
variable evaluates true. This is how we add ng-class
to first name: ng-class="{true:'hasError',false:'hasSuccess'}[hasError]"