2016-04-04 9 views
1

htmlにhrefとしてvar maplinkを表示したいと思います。私はすでに値を入力して、結果を表示したいmaplinkです。私はremoteMethodにmaplinkメソッドを作成しました。 maplinkは私のコンソールに表示されますが、htmlで表示するにはどうしたらいいですか?私はレスポンス本文をhtmlに表示するには

 [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

[mcve]を提供できますか? – Grundy

+0

おそらくもっと使います:[ng-map](https://ngmap.github.io/)? – Grundy

答えて

0

var maplink = "http://maps.google.com/?q=" + lat + "," + lng; 
    console.log('maplink is ' + maplink); 
    // make a callback function cb 
    cb(null, maplink); 

remoteMethodを( console.png

geocode.js私のfind-location.htmlに表示

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'); 
      }); 
    }; 
}]) 

geocode.jsしたいですbodyにangle.elementメソッドを使用して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); 
+0

コンソールから特定の結果を取得して別のタブを開くための関数として表示しますか? (Googleのapi結果) – sxxxxxxx

関連する問題