0

I am trying to embed a google map's iframe to my project, one per restaurant. The problem is that if the value of the addres is in:

$scope.restaurant.address

And I have to insert this code:

        <iframe width="450" height="250"
       src="https://www.google.com/maps/embed/v1/place?key=MY_KEY&q={{restaurant.address}}">
       </iframe>

{{restaurant.address}} is not correctly interpreted, and when the link is generated instead of the proper address, {{restaurant.address}} appears.

Any clue? Any help would be appreciated, thanks in advance!

1
  • have you tried ngSrc? Commented Apr 25, 2014 at 21:06

1 Answer 1

2

Try something like this:

app.controller('SomeController', function($scope, $sce){
    $scope.restaurant.address = '1313 Mockingbird Ln.';
    $scope.url = $sce.trustAsResourceUrl("https://www.google.com/maps/embed/v1/place?key=MY_KEY&q=" + $scope.restaurant.address);
});

HTML:

<iframe width="450" height="250" ng-src="{{url}}"></iframe>

You can read more about ngSrc here: https://docs.angularjs.org/api/ng/directive/ngSrc

$sce is a service that provides Strict Contextual Escaping services to AngularJS. https://docs.angularjs.org/api/ng/service/$sce

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.