javascript - Angular 2 - bypassSecurityTrustHtml along with bypassSecurityTrustScript -


i have button (on left navigation side), click on which, want display template (.html) on right side (content section). template (.html) path fetched web service , different every time (so no hard coded values).

that template (.html) can have it's own script tags. till angular 1.x easy ng-include tag, seems angular 2 not support anymore.

i able display html's content (as css) using below workaround -

this.sanitizer.bypasssecuritytrusthtml(url); 

but scripts not getting loaded or executed.

thanks in advance help.

the official document says bypasssecuritytrusthtml() should work in case.

i assuming must using [innerhtml] attribute populate contents in target container.

i had kind of similar reuirement needed single html tag single script tag. used bypasssecuritytrustresourceurl() that.

return this.sanitizer.bypasssecuritytrustresourceurl(url) 

i pretty sure work in case fetching executable source.

you can try combimation bypasssecuritytrustscript() , bypasssecuritytrusthtml().


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -