gabriela
gabriela

Reputation: 285

component inside iframe angular2

Is there a way to include a component inside an iframe in Angular 2?

This code doesn't work (it should render the angular component called component-b inside the iframe):

  var doc = document.getElementById('iframe').contentWindow.document;
    doc.open();
    doc.write('<component-b></component-b>');
    doc.close();

This code works (it renders a simple button inside the iframe):

 var doc = document.getElementById('iframe').contentWindow.document;
    doc.open();
    doc.write('<button></button>');
    doc.close();

Upvotes: 1

Views: 2290

Answers (1)

javadev28hu
javadev28hu

Reputation: 160

if you have an iframe inside an angular2 app that means, it is a totally different context. (separate application)

because of the above, the component/binding cannot work there.

the only thing you can do, that you bootstrap another angular applucation inside your iframe, but im sure you do not want that.

Upvotes: 2

Related Questions