How can I transfer an URL from ionic controller to .html file?



I need to transfer an URL address from an Ionic framework controller and has the URL web address to load in a <iframe>. I have now tried all sorts of $sce,trustAs and and $sce.getTrusted, but I just get a lot of errors, such as (from Firebug):

“Error: [$interpolate:noconcat] Error while interpolating: $sce.getTrustedUrl({{aSite}}) Strict Contextual Escaping disallows interpolations that concatenate multiple expressions when a trusted value is required. …”

The following reflects my code (I’m just keeping it extremely simple to solve the issue):

.controller('TestCtrl', function($sce) {
  $scope.aSite = $sce.trustAsUrl("");

And i my .html I try to show the URL in a <iframe> (it works fine if I just hard-code the URL in the html file, but in my program I need to use a dynamically created URL from the controller):

  frameborder="0" style="border:0"
  src= $sce.getTrustedUrl({{aSite}}) >

Any help highly appreciated. Thanks.


This is So easy to transfer an URL address from an Ionic framework
Define $sce in your controller and
put this code in your controller .

        $scope.video_path = {src:'Your Path'};

        $scope.trustSrc = function(src) {
            return $sce.trustAsResourceUrl(src);

And html will be like this

 <video ng-src="{{trustSrc(video_paths.src)}}" class="centerme" controls="controls" autoplay></video>