Open sison123 opened 6 years ago
it seems working for me. documentation might be incorrect.
Please follow this example, https://ngmap.github.io/#/!places-auto-complete.html
this.getPlace()
ng-repeat
with data
might cause an issue
this.getPlace()
-- this code works for me as well. my issue is,
i cant pass a paramter to placeChanged
function;
on-place-changed="placeChanged(data)"
it seems the data
is undefined in following code,
$scope.placeChanged = function (data) { console.log(data) // seems undefined here };
is there any solution for this..?
This is the same as, https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete
You need to get the data from your scope, not from your parameter.
Is it possible that this can be changed? Are you open to PRs?
My controllers are written with classes, so there's no decent way gain access to $scope
or my controller instance.
HTML:
<input ... places-auto-complete on-place-changed="$ctrl.onMapAutocompleteSelect('asdf')">
Controller:
export default class {
constructor($element, $q, $scope, ApiService, Logger) {
'ngInject';
Object.assign(this, { $element, $q, $scope, ApiService, Logger });
}
$onInit() {
this.loadCountries();
}
onMapAutocompleteSelect(arg) {
console.log('arg', arg); // can't pass any args
console.log('this', this); // this does not reference my controller instance
console.log('this.getPlace', this.getPlace()); // there's no way to get any reference to the html elements used
}
}
The only thing I can seemingly do is define a variable outside of my class, and assign it in $onInit
, which limits me to 1 instance of this controller at a time.
im using place-auto-complete in an array as follows,
$scope.placeChanged = function (data) { console.log(data) // seems undefined here };
is there any other way to solve this issue..!!