0

I am using iframe in my ionic app to open webpages inside the application.

Here is what I have:

  <iframe  class= 'webPage' name= "eventsPage" ng-src="{{object.url}}"></iframe>

The problem is that if I use ng-src="{{object.url}} or src="{{object.url}}for getting the URL the iframe doesnt not display anything but if I put hardcoded url instead (example http://www.google.com) it just works fine.

I have also check the output of the {{object.url}} and it's fine, a valid url (http://www.example.com).

Any suggestions ?

1 Answer 1

3

You need to inject the $sce service in the controller and trustAsResourceUrl the url there.

 <iframe   ng-src="{{trustSrc(object.url)}}"></iframe>

and in controller

 $scope.trustSrc = function(src) {
       return $sce.trustAsResourceUrl(src);
  }
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.