简体   繁体   English

如何仅将控制器变量的值作为参数传递给Ionic

[英]How to pass only the value of controller variable as argument in Ionic

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. 我试图将Google Maps自动完成API中提取的经度和纬度传递给基于这些坐标更新地图的函数。

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()" 我如何将变量{{details1.geometry.location.lat()}}和{{details1.geometry.location.lng()}}的值作为ng-blur =“中的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 file 控制器文件

.controller('pollutionMapCtrl', function($scope) {
 $scope.updateMap = function (lat,lng) {
    $scope.map = { center: { latitude: lat, longitude: lng }, zoom: 8 };
}

将参数传递给函数的方式与使用Javascript中的普通函数相同:

ng-blur="updateMap(details1.geometry.location.lat(), details1.geometry.location.lng())"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM