I want to display the content of a templated webpage inside an iframe. But after loading the content the template doesn't get interpolated by angular. Is it because the change detection system? Could it be achieved some other way?
@Component({
selector: 'my-app',
template : `<iframe [src]="template" width="100%" height="300px"></iframe>`
})
export class App {
template: string = `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Page title</title>
</head>
<body>
<p>{{strings[0]}}</p>
<p>{{strings[1]}}</p>
<p>{{strings[2]}}</p>
</body>
</html>
`;
strings: string[] = ['first element', 'second element', 'third element'];
constructor(){
this.template = 'data:text/html;charset=utf-8,' + encodeURI(this.template);
}
}
bootstrap(App)
http://plnkr.co/edit/mWrqv1?p=preview
It doesn't seem to work either using innerHtml
binding:
@Component({
selector: 'my-app',
template : `<div [innerHtml]="template"></div>`
})
export class App {
template: string = `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Page title</title>
</head>
<body>
<p>{{strings[0]}}</p>
<p>{{strings[1]}}</p>
<p>{{strings[2]}}</p>
</body>
</html>
`;
strings: string[] = ['first element', 'second element', 'third element'];
}
bootstrap(App)