如何在Angular 6中实现Sanitize库?

时间:2019-01-02 10:11:03

标签: angular angular6

哪个图书馆最适合消毒?由于它对安全性很有用,但是由于我们在angularjs中为依赖注入了依赖性,因此在angular6中实现的最佳方法是什么?

1 个答案:

答案 0 :(得分:0)

 //Import module first in your component - 

 import { DomSanitizer } from '@angular/platform-browser';

 // Create object for that inside constructor like below --
 constructor(public _domSanitizationService: DomSanitizer) {}


 // In your HTML file use like below.
 <img [src]="_domSanitizationService.bypassSecurityTrustUrl(url) />