1

I have a interesting problem to solve, but I don't know how, I have a dynamically inputs in my view, and the inputs in Angular are validated in realtime, but I don't want that, the angular inputs in input class "ng-invalid" and I want to add "ng-invalid" just when submit my form:

<div ng-if="conditionItem.field.id"
     ng-class="{'error': FieldConditionsCtrl.feedback.type === 'error'}"
     dynamic
     input-router << Here is my how generates the inputs
     source="conditionItem.field"
     ng-model="conditionItem.situation[$index]">
</div>

When I modify the generated input, AngularJS inputs in my input class the following classes "ng-invalid ng-empty":

enter image description here

I want to add this classes just when submit to make the border red. Any help for this issue?

2
  • 1
    You should not post code as an image because: meta.stackoverflow.com/a/285557/5535245 Commented Apr 9, 2019 at 22:43
  • 1
    He was just showing inside chrome developer tools. That is not an image of the code. Commented Apr 10, 2019 at 0:22

1 Answer 1

1

Used the $submitted property of the ngFormController to qualify the setting of the error class.

ng-class="{error: form1.$submitted && form1.field1.$invalid}"

For more information, see

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.