Files
bbq/src/app/shared/pipes/trushtml.pipe.ts
Taric Xin 8ead989ec1 edit
2021-12-27 18:35:24 +08:00

29 lines
614 B
TypeScript

/*
* @Description:
* @Author: wsm
* @Date: 2021-06-23 17:02:20
* @LastEditTime: 2021-06-23 17:04:57
* @LastEditors: wsm
* @Reference:
*/
import { Pipe, PipeTransform } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
@Pipe({
name: 'safehtml',
})
export class TrushtmlPipe implements PipeTransform {
constructor(private sanitizer: DomSanitizer) {}
transform(value: any, args?: any): any {
try {
if (!value || value === '') {
return '';
}
return this.sanitizer.bypassSecurityTrustHtml(value);
} catch (e) {
return '';
}
}
}