Запуск ng build --prod
дает мне следующую ошибку.
ОШИБКА в: неожиданный канал 'EscapeHtmlPipe в escape-html.pipe.ts', импортированный модулем 'AppModule в app.module.ts'.Пожалуйста, добавьте аннотацию @NgModule.
Отлично работает на ng serve
.Проблема только с ng build --prod
Код в файле приведен ниже
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import{ EscapeHtmlPipe } from '../../Shared/pipes/escape-html.pipe';
@NgModule({
imports: [CommonModule],
declarations: [EscapeHtmlPipe],
exports: [EscapeHtmlPipe]
})
export class EscapeHtmlModule { }
Файл кода для канала указан ниже
import { Pipe, PipeTransform } from '@angular/core';
import { SafeHtml, SafeStyle, SafeScript, SafeUrl, SafeResourceUrl, DomSanitizer } from '@angular/platform-browser';
@Pipe({
name: 'escapeHtml'
})
export class EscapeHtmlPipe implements PipeTransform {
constructor(protected sanitizer: DomSanitizer) { }
transform(value: any, type: string): SafeHtml | SafeStyle | SafeScript | SafeUrl | SafeResourceUrl {
switch (type) {
case 'html': return this.sanitizer.bypassSecurityTrustHtml(value);
case 'style': return this.sanitizer.bypassSecurityTrustStyle(value);
case 'script': return this.sanitizer.bypassSecurityTrustScript(value);
case 'url': return this.sanitizer.bypassSecurityTrustUrl(value);
case 'resourceUrl': return this.sanitizer.bypassSecurityTrustResourceUrl(value);
default: throw new Error(`Invalid safe type specified: ${type}`);
}
}
}
в AppModule, который я сделалthis
import { EscapeHtmlModule } from './Module/escape-html/escape-html.module';
часть NgModule приведена ниже
NgModule({
declarations: [
AppComponent,
// EscapeHtmlPipe,
NavMenuComponent,
OpportunityComponent,
HomeComponent,
FileUploadComponent,
TinymceComponent,
SummaryComponent,
OpportunityListComponent
],
imports: [
BrowserModule,
MaterialModule,
FormsModule,
ReactiveFormsModule,
AppRoutingModule,
BrowserAnimationsModule,
HttpClientModule,
DragDropModule,
ScrollDispatchModule,
EditorModule,
// EscapeHtmlPipe,
DragulaModule.forRoot(),
ContextMenuModule.forRoot(), EscapeHtmlModule
],
providers: [
RFPDocumentService,
ColorChangeService,
CategoryService,
InsertCategoryAttributeService
],
bootstrap: [AppComponent],
entryComponents:[TinymceComponent,OpportunityListComponent]
})
Но проблема даже существовала до того, как я добавил EscapeHtmlModule в промежуточное ПО, так как ранее я добавлял канал непосредственно в AppModule иэто генерировало ошибку.Любая помощь будет оценена Спасибо