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')" ..

demo plunk


Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -