angular-google-places-autocomplete
angular-google-places-autocomplete copied to clipboard
Converting Places to Address
Hey,
When I am selecting "Times Square NY" from dropdown, it is getting converted to "Manhattan, NY 10036, United States" .
But i want to display "Times Square NY" only. Please help.
Trying to solve the same problem...Did you get anywhere with this?
Figured it out.
In the directive's format(modelValue) function the viewValue is set. Simply change the value in the else if clause like so: viewValue = modelValue.name; (line 225)
.name can be changed to any other place attribute you may want to set it as.
I verify this solution. I've changed the whole block to look like this:
if (isString(modelValue)) {
viewValue = modelValue;
} else if (isObject(modelValue)) {
if (isString(modelValue.name)) {
viewValue = modelValue.name;
} else {
viewValue = modelValue.formatted_address;
}
}
I've seen this code too, but is there a hook to configure this? I don't want to rewrite the code. I just want to pass in an option to the angular-google-places-autocomplete directive to tell it what field on the 'place' to use.
Is it possible to configure it for this? If so, how?
I issued a merge request to address this issue, but it hasn't been merged yet.
You can grab my version from here: https://github.com/nbpayne/angular-google-places-autocomplete
Add this to your bower.json
.
"angular-google-places-autocomplete": "https://github.com/nbpayne/angular-google-places-autocomplete.git#500dcbc"
This feature should really be merged. It's essential.
Just ran into the same issue. Seems like this fix should be the default - confusing for the user to have the input value not show the name of the place that was selected.