Angular 2 - Form is invalid when browser autofill

前端 未结 7 1912
广开言路
广开言路 2021-01-31 16:48

I have a Login Form which has email and password fields.

I\'ve chosen for browser autofill.

The problems is: When browser autofills login form, both fields are p

7条回答
  •  后悔当初
    2021-01-31 17:16

    I solved this problem with the ChangeDetectorRef Provider.
    Simply do a manual detectChanges() before you check if the input is valid.

    If you aren't able to check after a button click, then hear on the Input-Event of the Input-Element with the event-binding (input)=changedetectorfunc() and call the changeDetector in this function.
    Therefore it must work.
    Hope, it helps you.

    useful links:

    • https://angular.io/api/core/ChangeDetectorRef
    • Angular 2 change event on every keypress

    Best wishes

提交回复
热议问题