Tom Cohen
Tom Cohen

Reputation: 163

pass argument into iframe src

I have two blocks of code

First:

function readJason() {
  var mainInfo = null;
  var _DATA_FOLDER = process.env.LOCALAPPDATA + '/dmv/dmv.data/cameraUrl.json';
  $http.get(_DATA_FOLDER).success(function(data) {
    mainInfo = data;
    var url = mainInfo.url;
    cameraDialog(url);
  });
}

Now url parameter holds https://www.google.com for example.

Second:

function cameraDialog(url) {
  $mdDialog.show({
    template: `<md-dialog class="fullscreen-dialog" layout="column"><iframe src='url' scrolling="yes" frameborder="0" style="position: relative; height: 100%; width: 100%;">
            </iframe></md-dialog>`,
  })
}

How can i insert url parameter into src ? (like the way i did it's wrong)

THANKS !

Upvotes: 0

Views: 514

Answers (2)

engineforce
engineforce

Reputation: 3020

template(ES6/2015):

{
    template: `<md-dialog class="fullscreen-dialog" layout="column"><iframe src='${url}' scrolling="yes" frameborder="0" style="position: relative; height: 100%; width: 100%;">
            </iframe></md-dialog>`,
  }

Or

template(legacy):

{
    template: '<md-dialog class="fullscreen-dialog" layout="column"><iframe src="'+url+'" scrolling="yes" frameborder="0" style="position: relative; height: 100%; width: 100%;">
            </iframe></md-dialog>',
  }

Upvotes: 1

Ali K Al Azzeh
Ali K Al Azzeh

Reputation: 17

use this instead :

template: '<md-dialog class="fullscreen-dialog" layout="column"><iframe src="' + url + '" scrolling="yes" frameborder="0" style="position: relative; height: 100%; width: 100%;"></iframe></md-dialog>'

Upvotes: 0

Related Questions