angular - How to avoid adding prefix “unsafe” to link by Angular2? -
this question has answer here:
using angular2, there setting avoid adding prefix “unsafe:” links. need set links protocol not whitelisted default in angular2, needed our internal applicaion, result invalid link:
<a href="unsafe:notes://myserver/c1256d3b004057e8" ..
in older angular there compileprovider.ahrefsanitizationwhitelist, cannot find similar in angular2.
use domsanitizer
:
import {domsanitizer} '@angular/platform-browser'; ... constructor(private sanitizer:domsanitizer){} ... let sanitizedurl = this.sanitizer.bypasssecuritytrusturl('notes://myserver/c1256d3b004057e8');
or create method return sanitized url:
sanitize(url:string){ return this.sanitizer.bypasssecuritytrusturl(url); }
and in template:
<a [href]="sanitize('notes://myserver/c1256d3b004057e8')" ..
Comments
Post a Comment