我想在我的html中将var映射链接显示为href。我已经在中输入了值,结果就是我想要显示的地图链接。我在remoteMethod中创建了maplink方法。地图链接显示在我的控制台中,我如何让它显示在html中?我想在我的find-location.html中显示它console.png
geocode.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');
});
};
}])
geo-code.js
var maplink = "http://maps.google.com/?q=" + lat + "," + lng;
console.log('maplink is ' + maplink);
// make a callback function cb
cb(null, maplink);
remoteMethod()
[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方法选择body并将maplink附加到它。检查下面的代码。
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);