1

I have input with type date in angular form and rendered with the default value(For ex: "1/1/2019").

Based on the sources on form reset, when we reset a form, the value of the form elements will reset to its initial value.

So, in this case, if i reset my angular form, the form's input element retains its original value. But, even the valid value is present in the input element.

ng-invalid class gets added to the input element?

Also, I have another doubt.

Please, check this sample below.

https://stackblitz.com/edit/angular-krw9jz-f5c7af?file=index.html

Here, i have used inputs for representing angular ngmodel binding and an normal JS input element with value attribute.

I have set the value for the two elements initially. So, as per the JS reset form standard, the initial given value retains. But, in angular the value of input changes null when resetting the form.

Please, let me know why this weird behavior followed in angular form?

2
  • Could you provide an example. You can use stackblitz or plunker? Commented Feb 8, 2019 at 9:27
  • Try some of the debugging techniques mentioned here: angular.io/guide/forms have a look at ` #spy` {{spy.className}}. I also suspect that you are setting the date in the incorrect format. There is probably an internal vs external representation. stackoverflow.com/questions/45330319/… Commented Feb 8, 2019 at 9:46

0

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.