gpt4 book ai didi

javascript - 如何将响应正文显示为html

转载 作者:太空宇宙 更新时间:2023-11-04 02:14:23 25 4
gpt4 key购买 nike

我想在我的 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);

关于javascript - 如何将响应正文显示为html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36395736/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com