我想在我的 html 中将 var maplink 显示为 href。我已经输入了值,结果是我想要显示的 map 链接。我在remoteMethod 中创建了maplink 方法。 map 链接显示在我的控制台中,如何让它显示在 html 中?我想在我的 find-location.html 中显示它 console.png
地理编码.js
angular
.module('app')
.controller('FindLocationController', ['$scope', '$state', 'GeoCode', function ($scope, $state, GeoCode) {
$scope.GeoCodes = [];
$scope.submitForm = function () {
GeoCode
.geocode({
address: $scope.geoCode.address,
zipCode: $scope.geoCode.zipCode,
city: $scope.geoCode.city,
})
.$promise
.then(function () {
$state.go('find-location');
});
};
}])
地理代码.js
var maplink = "http://maps.google.com/?q=" + lat + "," + lng;
console.log('maplink is ' + maplink);
// make a callback function cb
cb(null, maplink);
远程方法()
[GeoCode.remoteMethod(
'geocode', {
http: {
path: '/geocode',
verb: 'post'
},
accepts: \[{
arg: 'address',
type: 'string',
required: true
}, {
arg: 'city',
type: 'string',
required: true
}, {
arg: 'zipCode',
type: 'string',
required: true
}\],
returns: {
arg: 'maplink',
type: 'string',
}
}
);
使用 angular.element 方法选择主体并向其附加 map 链接。检查下面的代码。
var maplink = "http://maps.google.com/?q=" + lat + "," + lng;
console.log('maplink is ' + maplink);
// Append maplink to body
var body = angular.element( document.querySelector( 'body' ) );
body.append(maplink);
// make a callback function cb
cb(null, maplink);
我是一名优秀的程序员,十分优秀!