6

For a simple login form, the login button is set to be disabled like following: [disabled]="!password || !loginName" And Chrome autocomplete will fill in those value. But after the page is loaded with loginName and password auto filled in, the button still disabled at the first load. I have to click somewhere on the page or click the button directly to login. [This is not preventing the click event to be captured, but the UI will display as disabled.]

Vincent
  • 1,178
  • 1
  • 12
  • 25
  • Have you tried with a more specific condition? like `password !== ""` instead of `!password` – Supamiu Oct 12 '16 at 09:40
  • `Chrome autocomplete will fill in those value`: It fills password field too? If yes, then use `autocomplete="off"` html attribute for password field. – Ajeet Shah Oct 12 '16 at 10:02
  • @Supamiu yes I tried but same. I think the issue is that ng2 added `disabled` attribute before autocomplete filled in but not changing this afterwards. – Vincent Oct 12 '16 at 10:08
  • @AjeetShah autocomplete="off" does not seem to work in Chrome, there are plenty of threads talking about this. (actually it have this tag but auto filled in still) – Vincent Oct 12 '16 at 10:10
  • I just ran into this exact issue myself. Were you able to solve this? – nhaesler Jan 17 '17 at 17:22
  • @nhaesler programme a function and loops in ngAfterContentChecked, a bad practice... – Vincent Jan 18 '17 at 12:50
  • See this answer: https://stackoverflow.com/a/15917221/11322237 – Gabriel Arghire Jul 29 '22 at 12:18

1 Answers1

0

Can you try readonly attribute in your input?

[readonly] = "!password || !loginName"
barış çıracı
  • 1,033
  • 14
  • 16