Closed sangha-pareto closed 5 months ago
This looks like a bug in MatGoogleMapsAutocompleteComponent. How can I help resolve this issue or find a workaround?
The component template contains an input bound to the address property:
... <input matInput [(ngModel)]="address" ...
The address property is defined as
address: PlaceResult | string;
This input displays the address successfully when an address is selected because in initGoogleMapsAutocomplete the listener explicitly sets the address property to a string: this.address = place.formatted_address;
On form patchValue the writeValue method value is called successfully. However, I can't see any code that updates the address property. So the form control does not show the patchValue address. Maybe the intended behavior here is that the listener should fire?
writeValue(obj) {
if (obj) {
this.value = obj; // This line is successfully run on patchValue
}
}
are you using the latest version?
PR is appreciated guys
Bug Report
OS and Version?
macOS Catalina v. 10.15.7
Versions
Repro steps
Please see the following code.
HTML:
TS:
The log given by the failure
No errors in the logs.
Desired functionality
I would like to see the autocomplete directive patched with the value I am passing it in
getData()
. I did see issue #319 where the user is patching a string. However, I am trying to patch a PlaceResult object as suggested by the library owner in that issue but it still does not work. I do understandmyAddress
is not the full PlaceResult object but I have tried it. I chose this condensed version for the sake of simplicity.Can someone explicitly show me an example of how to update the autocomplete control's value?
Thank you for your help.