我升级到Angular 8,并且在更新所有内容后,我在浏览器上发现了此错误
此处管道代码
import {Pipe, PipeTransform} from '@angular/core';
import {DomSanitizer, SafeHtml} from '@angular/platform-browser';
@Pipe({
name: 'bypassSanitizer'
})
export class BypassSanitizerPipe implements PipeTransform {
constructor(private domSanitizer: DomSanitizer) {
}
transform(html: string): SafeHtml {
if (html) {
return this.domSanitizer.bypassSecurityTrustHtml(html);
} else {
return '...';
}
}
}
这里是管道模块代码
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { BypassSanitizerPipe } from './bypass-sanitizer.pipe';
@NgModule({
declarations: [
BypassSanitizerPipe
],
providers: [
BypassSanitizerPipe
],
imports: [
CommonModule
],
exports: [
BypassSanitizerPipe
]
})
export class CorePipeModule {
static forRoot() {
return {
ngModule: CorePipeModule,
providers: [],
};
}
}
答案 0 :(得分:0)
我解决了这个问题,只是从管道模块中删除了提供程序
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { BypassSanitizerPipe } from './bypass-sanitizer.pipe';
@NgModule({
declarations: [
BypassSanitizerPipe
],
imports: [
CommonModule
],
exports: [
BypassSanitizerPipe
]
})
export class CorePipeModule {
static forRoot() {
return {
ngModule: CorePipeModule,
providers: [],
};
}
}