2

The form uses google places api to get adresses but clicking on a adress (or selecting it with the keybord) will not trigger a revalidation of the form?

https://plnkr.co/edit/LgEn9t0X2h6BTHGwyJOW?p=preview

I update the value with

this.registrationForm.patchValue({ adress: adress.formatted_address});

and have tried to trigger the validation manually using the methods

this.registrationForm.markAsDirty(true);

and

this.registrationForm.updateValueAndValidity();

but cant get it to work.

1 Answer 1

3

As place_changed event is fired outside angular zone i would suggest we should call zone.run() like

constructor(private zone: NgZone) {}

...
google.maps.event.addListener(this.autocomplete, 'place_changed', () => {
    const place = this.autocomplete.getPlace();
    this.zone.run(() => this.invokeEvent(place));

Forked Plunker

See also

Sign up to request clarification or add additional context in comments.

1 Comment

ah.. I was assuming that the form update using patchValue would trigger the form to revalidate.. Thx! :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.