Using $http to display page within an iframe


#1

Greetings,

My goal is to display an external website within the tags using iframe and the $http service, all while keeping the nice side menu.

The issue is even after following the documentation, I can’t seem to make it work. The ionic server console spits out the following on page reload:

ReferenceError: $scope is not defined

Window Controller in “app.js”

app.controller('WindowCtl', function($scope, $http){ $http.get("<url>").then(function(response){ console.log('Got a response:', response.data); $scope.html = response.data; }); });

“index.html”

<ion-side-menus> <ion-side-menu-content> <div class="bar bar-header bar-dark bar-outline"> <button class="button button-clear icon ion-navicon" ng-click="showMenu()"></button> <h1 class="title">Hello</h1> <button class="button button-clear icon ion-ios-cart-outline" on-tap="search()" ng-click="search()"></button> </div> Left Menu Content </ion-side-menu-content> <ion-side-menu side="left"> Left Menu! </ion-side-menu> </ion-side-menus> <ion-content> <iframe id="site-frame" class="window" ng-bind-html='html' ng-controller='WindowCtl'> {{$scope.html}} </iframe> </ion-content>

Has anyone encountered this before? Thank you in advance.


#2

use $sce in ur controller and $scope.trustedContent = $sce.trustAsHtml($scope.htmlt);