我正在尝试将提取的经度和经度从Google地图自动完成API传递到根据这些坐标更新地图的功能。
如何传递变量{{details1.geometry.location.lat()}}和{{details1.geometry.location.lng()}}的值作为ng-中updateMap()函数的参数模糊=" 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 };
}
答案 0 :(得分:1)
将参数传递给函数的方式与Javascript中的普通函数相同:
ng-blur="updateMap(details1.geometry.location.lat(), details1.geometry.location.lng())"