I have an API that returns HTML code (which contains iframe object).
The code that is sent to client looks like this:
<p>Something blabla</p>
<iframe allowfullscreen="true" frameborder="0" height="270" src="https://www.youtube.com/embed/someID?feature=oembed" width="480"></iframe>
Now, how can I add an exception to sanitizer only for YouTube? The problem is, the HTML code is user input (not fully user input, but only to people I trust, so I guess there is no security risk), so I can't use bypassSecurityTrustResourceUrl, right?
My code (page.component.ts)
constructor(private _router: Router, private _http: Http, private _sanitizer: DomSanitizer) {
this.fetchNews();
}
fetchNews() {
this._http
.get(this.urlAPI)
.map((response: Response) => {
let json = response.json();
this.content = json.results[0].content;
}).subscribe();
}
And HTML (page.component.html):
<div [innerHTML]="content">
</div>