Reputation: 285
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
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