【发布时间】:2016-11-23 02:54:49
【问题描述】:
我将如何对这个 js 函数进行角度化?我需要它异步使用。我的理解是 .then 和 angular 可以做到这一点。
function showResult(result) {
var lat = result.geometry.location.lat();
var long = result.geometry.location.lng();
$scope.vm.showroom.Longitude = long;
$scope.vm.showroom.Latitude = lat;
}
function GetLatitudeLongitude(callback, address) {
var address1 = address || '234 eisenhower avenue salt lake city';
// Initialize the Geocoder
var geocoder = new google.maps.Geocoder();
if (geocoder) {
geocoder.geocode({
'address': address1
}, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
callback(results[0]);
}
});
}
}
【问题讨论】:
-
查看 Angular 中的
$q服务 docs.angularjs.org/api/ng/service/$q