javascript - How to apply ng-class on button click -


this question has answer here:

plunker.

to textbox want apply errorhilight class when ng-model contains '' or undefined, , when submit button click need's check.

<input type="text" class ="errorhilight" ng-model="name"  ng-class="{'errorhilight': (name == '' || name == 'undefined')}"> 

how can apply errorhilight class on button click.

there many ways it. example

<input type="text" ng-model="name"  ng-class="{errorhilight: highlighterrors && !name}"> <input type="submit" ng-click="validate();">  $scope.validate = function(){   $scope.highlighterrors = true } 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -