2016-04-04 6 views
1

Ich möchte die Var Maplink als href in meinem HTML anzeigen. Ich gebe die Werte bereits ein und das Ergebnis ist der Maplink, den ich anzeigen möchte. Ich habe die Maplink-Methode in remoteMethod erstellt. Der Maplink wird in meiner Konsole angezeigt, wie kann ich ihn in HTML anzeigen lassen? Ich will es console.pngWie Antwortkörper in HTML anzuzeigen

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

geocode.js

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

remoteMethod() in meinem Fund-location.html anzuzeigen

 [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

Können Sie [mcve] bereitstellen? – Grundy

+0

möglicherweise besser verwenden: [ng-map] (https://ngmap.github.io/)? – Grundy

Antwort

0

Wählen Sie den Körper mit der angle.element-Methode aus und hängen Sie maplink daran an. Überprüfen Sie den folgenden Code.

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

Wird das bestimmte Ergebnis von der Konsole abgerufen, um es als Funktion zum Öffnen einer anderen Registerkarte anzuzeigen? (Google API-Ergebnis) – sxxxxxxx

Verwandte Themen