4

I am trying to load a map on each page that is specific to the values from an api, but I am getting this error message:

Strict Contextual Escaping disallows interpolations that concatenate multiple expressions when a trusted value is required. See http://docs.angularjs.org/api/ng.$sce http://errors.angularjs.org/1.2.15/$interpolate/noconcat?

Here is the markup:

<div ng-bind-html="trustedHtml" class="col-md-4 map">
    <iframe ng-src="https://www.google.com/maps/embed/v1/placekey=AIzaSyAJ_lVIxNq31PmzRUbMh9JIStQOE4_6-aQ&q='{{event.venue.name}}'"/>
</div>

and here is the controller:

.controller('EventsCtrl', function($scope, EventsFactory, $routeParams, $sce){
    EventsFactory.async().then(function(data){
        $scope.events = data.data;
        $scope.event= findEvent(eventId, $scope.events);
        console.log($scope.event);
        $scope.trustedHtml = $sce.trustAsHtml($scope.event);
AndrewPolland
  • 3,041
  • 4
  • 28
  • 39
user26202
  • 53
  • 1
  • 7

1 Answers1

0

Instead of using $sce.trustAsHtml(), try using $sce.trustAsResourceUrl(). Place your whole URL as parameter for $sce.trustAsResourceUrl(). The link below worked for me.

How to set an iframe src attribute from a variable in AngularJS

Community
  • 1
  • 1
Ardee Aram
  • 4,740
  • 8
  • 36
  • 37