1

I want to open a modal popup with angular, and have it open the Url that I passed as parameter. I can't figure out how to open the url inside the modal popup window. This is what I have so far: ($scope.targetUrl would be for example "http://www.google.de")

var modalWindowOptions = {
    templateUrl: 'app/modal.tpl.html',
    controller: function($scope, $modalInstance, targetUrl) {
        $scope.init = function() {
            console.log(platformUrl);
        }
    },
    resolve: {
        targetUrl:  function () {
            return  $scope.targetUrl;
        }
    }
};

$modal.open(modalWindowOptions)
      .result.then(onPopupClose, onPopupClose, onPopupClose);

function onPopupClose() {
    console.log('closed popup!');
};

and the template:

<div data-ng-init="init()" style="width:500px; height: 600px;">
    <p ng-bind="targetUrl"></p>
</div>

What should I do in the init function? I tried everything possible for at least 6 hours now, $location, etc etc. I expected this to work easily just like window.open(url), but I'm missing something. Thanks

Fayyaz Naqvi
  • 695
  • 7
  • 19
Amc_rtty
  • 3,662
  • 11
  • 48
  • 73
  • Please have a look at this [SO question](http://stackoverflow.com/questions/24634930/unable-to-load-url-into-iframe-via-angularjs-controller). You have to use `ng-src` and `trustAsResourceUrl` from `$sce` to load your content into an iframe. That's possible if `x-origin-framing` is allowed by the server. – AWolf Oct 30 '15 at 20:47

0 Answers0