#Reactive Forms default value with Signals and ProvideExperimentalZonelessChangeDetection

7 messages · Page 1 of 1 (latest)

subtle lagoon
#

Trying to set default value on a form control with data from external API call, but it does not update the form control value when the data is fetched.

Did find a solution to this using Effect, but wondering if anyone else has a more elegant solution.

#

I assume this is because I am using ProvideExperimentalZonelessChangeDetection()

marble sky
#

No. It's because fetching data from a server is asynchronous. So when you initialize your form (immediately after sending the request), the response hasn't been received yet.

subtle lagoon
#

Okey, thx for info.

Would using Effect be okey here do you think?

#

It works, just wondering if it's a bad pattern

marble sky
#

Your company signal looks useless. I would simply subscribe to the observable and populate the form from there.

subtle lagoon
#

The code is simplified as an example.
The signal is being used in my template and component