For example we want to build pipe to sanitizer the url:
@Pipe({ name: 'safeUrl' }) export class SafeUrlPipe implements PipeTransform { constructor(private sanitizer: DomSanitizer) { } transform(url){ return this.sanitizer.bypassSecurityTrustResourceUrl(url); } }
bypassSecurityTrustUrl which says
Bypass security and trust the given value to be a safe style URL, i.e. a value that can be used in hyperlinks or
<img src>
bypassSecurityTrustResourceUrl which says
Bypass security and trust the given value to be a safe resource URL, i.e. a location that may be used to load executable code from, like
<script src>
, or<iframe src>
.