In creating this share module, I have included the following components:
@NgModule({
declarations: [
, DateToPersian
, EnumToArrayPipe
, SearchWtihInput
, ConvertbytePipe
, ArraySortPipe
, MonySplitePipe
, IsEllipsisActiveDirective
],
imports: [
CommonModule,
FormsModule,
MaterialFileInputModule,
MatDatepickerModule,
// use this if you want to use native javascript dates and INTL API if available
// MatNativeDatetimeModule,
MatDatepickerModule,
ReactiveFormsModule,
MaterialModule,
FormsModule,
TranslateModule.forChild()
],
providers: [LogHelper, DateService,
{ provide: DateAdapter, useClass: MaterialPersianDateAdapter, deps: [MAT_DATE_LOCALE] },
{ provide: MAT_DATE_FORMATS, useValue: PERSIAN_DATE_FORMATS }
],
exports: [
MaterialModule
, ConvertbytePipe
, DateToPersian
, EnumToArrayPipe
, SearchWtihInput
, MonySplitePipe
, ArraySortPipe
, IsEllipsisActiveDirective
],
})
export class SharedModule {
static forRoot(): ModuleWithProviders {
// Forcing the whole app to use the returned providers from the AppModule only.
return {
ngModule: SharedModule,
providers: [LogHelper, DateService,
{ provide: DateAdapter, useClass: MaterialPersianDateAdapter, deps: [MAT_DATE_LOCALE] },
{ provide: MAT_DATE_FORMATS, useValue: PERSIAN_DATE_FORMATS }
],
};
}
}
When calling this in the app.module
,
SharedModule.forRoot(),
An error is displayed when running the project:
ERROR in src/app/shared/shared.module.ts(22,18): Error during template compile of 'SharedModule' Expression form not supported.
src/app/shared/shared.module.ts(22,18): Error during template compile of 'SharedModule' Expression form not supported.
Cannot determine the module for class ConvertbytePipe in E:/MyProject/Ava/PFA/demo/src/app/shared/pipes/convertbyte.pipe.ts! Add ConvertbytePipe to the NgModule to fix it.
Cannot determine the module for class DateToPersian in E:/MyProject/Ava/PFA/demo/src/app/shared/pipes/date-to-persian.pipe.ts! Add DateToPersian to the NgModule to fix it.
Cannot determine the module for class EnumToArrayPipe in E:/MyProject/Ava/PFA/demo/src/app/shared/pipes/EnumToArrayPipe.ts! Add EnumToArrayPipe to the NgModule to fix it.
Cannot determine the module for class SearchWtihInput in E:/MyProject/Ava/PFA/demo/src/app/shared/pipes/saerch-with-input-pipe.ts! Add SearchWtihInput to the NgModule to fix it.
Cannot determine the module for class MonySplitePipe in E:/MyProject/Ava/PFA/demo/src/app/shared/pipes/mony-splite.pipe.ts! Add MonySplitePipe to the NgModule to fix it.
Cannot determine the module for class ArraySortPipe in E:/MyProject/Ava/PFA/demo/src/app/shared/pipes/sort-pipe.ts! Add ArraySortPipe to the NgModule to fix it.
Cannot determine the module for class IsEllipsisActiveDirective in E:/MyProject/Ava/PFA/demo/src/app/shared/directives/is-ellipsis-active.directive.ts! Add IsEllipsisActiveDirective to the NgModule to fix it.
Cannot determine the module for class PrettyShowJson in E:/MyProject/Ava/PFA/demo/src/app/shared/pipes/pretty-json.ts! Add PrettyShowJson to the NgModule to fix it.
To address this issue, you can try the following solutions: