Reputation: 149
I am trying to pass the extracted latitude and longitude from the google maps autocomplete API to a function that updates the map based on those coordinates.
How do i pass the value of the variables {{details1.geometry.location.lat()}} and {{details1.geometry.location.lng()}} as arguments for the updateMap() function in ng-blur="updateMap()"
<ion-content padding="true" class="has-header" ng-controller = "pollutionMapCtrl">
<label class="item item-input" id="address-input" name="address">
<i class="icon ion-search placeholder-icon"></i>
<input id = "Autocomplete" type="text" ng-autocomplete ng-model = "result1" details = "details1" options = "options1" ng-blur="updateMap()">
</label>
<div>result: {{result1}}</div>
<div>lat: {{details1.geometry.location.lat()}}</div>
<div>long: {{details1.geometry.location.lng()}}</div>
controller file
.controller('pollutionMapCtrl', function($scope) {
$scope.updateMap = function (lat,lng) {
$scope.map = { center: { latitude: lat, longitude: lng }, zoom: 8 };
}
Upvotes: 0
Views: 91
Reputation: 193261
You pass arguments to functions the same way you do with normal function in Javascript:
ng-blur="updateMap(details1.geometry.location.lat(), details1.geometry.location.lng())"
Upvotes: 1