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 -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -