0

I have simple Form validation, when Form is submitted

$scope.error shows error if there is any exist

<div class="card" ng-show="error">
  <div class="item item-text-wrap assertive">
    {{error}}
  </div>
</div>

Is there way to reset $scope.error if any element in form gets focused?

karma
  • 903
  • 10
  • 26
  • `ngFocus` is in there for an event based function.. https://docs.angularjs.org/api/ng/directive/ngFocus – Pogrindis Aug 10 '15 at 11:04
  • so to check any element, i should have ng-focus on all elements? – karma Aug 10 '15 at 11:07
  • you could define a directive to monitor all input types.. but it would be a bit of work! http://stackoverflow.com/questions/14833326/how-to-set-focus-on-input-field – Pogrindis Aug 10 '15 at 11:09
  • so then directive will be injected in all input types, if I understand it right?! ok, directive or ng-focus might actually help, but in case of directive, Can I change scope variable from directive? – karma Aug 10 '15 at 11:13

1 Answers1

0

you can use ng-focus in each fields

<input type="text"  ng-focus="error=false" />
<div class="card" ng-show="error">
  <div class="item item-text-wrap assertive">
    {{error}}
  </div>
</div>
Vaibhav Shah
  • 538
  • 3
  • 16