javascript - How to apply ng-class on button click -
this question has answer here:
- angular ng-class if-else expression 7 answers
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
Post a Comment