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?

  • Could you provide an example. You can use stackblitz or plunker? – yunzen Feb 08 '19 at 09:27
  • Try some of the debugging techniques mentioned here: https://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. https://stackoverflow.com/questions/45330319/angular2-setting-date-field-on-reactive-form/45330707#45330707 – JGFMK Feb 08 '19 at 09:46

0 Answers0