I went through angular documentation for both functions
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>.
both of the above is used to bypass security and trust.
I was bypassing the blob url for <img src> ,so before going through the documentation, my IDE (vscode) presented the above two functions, and I used bypassSecurityTrustResourceUrl and my code was like...this.
component.ts
this.fileService.getFileBlobUrl(imgsrc).subscribe(url => {
this.domSanitizer.bypassSecurityTrustResourceUrl
user.bloburl = this.domSanitizer.bypassSecurityTrustResourceUrl(url);
});
component.html
<img [src]="user.bloburl" class="avatar" alt="avatar">
as per documentation bypassSecurityTrustUrl should be working. but I used 'bypassSecurityTrustResourceUrl`
and it is actually working!!!!
So my question is what is the difference between those two functions. why two different function if any of them can be used?