When a user clicks on a point on a Google map, I am conducting reverse geocoding in the following manner:
geocoder.geocode({'location': latlng}, function(results, status) {
if (status === google.maps.GeocoderStatus.OK) {
if (results[1]) {
console.log(results[1]);
After this step, the console log for results[1] appears as follows:
Object {address_components: Array[4], formatted_address: "Rathmines, Co. Dublin, Ireland", geometry: Object, place_id: "ChIJN6MDC6kOZ0gRIhArCabX9o4", types: Array[2]}
However, when I attempt to pass that object into an ng-click function upon the user tapping on the infowindow with the address displayed, like so:
ng-click='addressPicked("+results[1]+")'
I encounter the error:
Error: [$parse:syntax] Syntax Error: Token 'Object' is unexpected, expecting []]
at column 23 of the expression [addressPicked([object Object])] starting at [Object])].
I have successfully implemented a similar feature in another application where only latitude and longitude strings were passed through.
Is it necessary for me to convert the object into a different form before attempting to use it as a parameter?
Has anyone faced this error before with ng-click?
Any assistance would be greatly appreciated. Thank you.