我想在我的html中将var maplink显示为href。我已经输入了值,结果是我要显示的maplink。我在remoteMethod中创建了maplink方法。 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');
});
};
}])
地理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',
}
}
);
答案 0 :(得分:0)
使用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);