0
我試圖將提取的經度和緯度從Google地圖自動完成API傳遞到基於這些座標更新地圖的函數。如何僅傳遞控制器變量的值作爲Ionic中的參數
如何將變量{{details1.geometry.location.lat()}}和{{details1.geometry.location.lng()}}的值作爲updateMap()函數的參數傳遞給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('pollutionMapCtrl', function($scope) {
$scope.updateMap = function (lat,lng) {
$scope.map = { center: { latitude: lat, longitude: lng }, zoom: 8 };
}