UI Consultant, Maker & Technical Writer.
I write about JS, TS, Rx, Angular & all things Front End
🇮🇹🇬🇧
Follow me on Twitter: https://twitter.com/gc_psk
Founder of https://makerkit.dev
Then the ngOnChanges will be called first with only email and then with only username so one of the two is undefined. Only the values that are changed are submitted in the SimpleChanges
It depends what do you want to achieve with this function.
Like I read this it should only take the email into account if the name is empty so something like this:
Hi! do you mean that name or email could be undefined? TBH I'd never ship this to production - just needed a short example with multiple inputs 😅
Ok so if you have a component that uses your code like this
If the input of the observables look like this
Then the ngOnChanges will be called first with only
email
and then with onlyusername
so one of the two is undefined. Only the values that are changed are submitted in theSimpleChanges
And what's the solution to avoid this situation, please? Would you opt by adding a setter to the property?
It depends what do you want to achieve with this function.
Like I read this it should only take the email into account if the name is empty so something like this:
Thanks for replying asap! Best regards.