新建一个管道文件

import { Pipe, PipeTransform } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
@Pipe({
name: "html"
})
export class HtmlPipe implements PipeTransform {
constructor(private sanitizer: DomSanitizer) {
}
public transform(style) {
return this.sanitizer.bypassSecurityTrustHtml(style);
}
}
 
在需要的module下引入
import { HtmlPipe } from '../pipe';
declarations: [
iComponent,
HtmlPipe
],
 
在html 中
<p *ngIf='checked' [innerHTML]="transformValue | html"></p>

相关文章:

  • 2021-11-27
  • 2021-05-29
  • 2022-12-23
  • 2021-10-09
  • 2022-12-23
  • 2019-06-17
  • 2022-12-23
  • 2021-06-14
猜你喜欢
  • 2022-12-23
  • 2021-07-29
  • 2022-12-23
  • 2021-12-29
  • 2021-09-16
  • 2022-12-23
相关资源
相似解决方案