我已将一个组件用作另一个组件页面中的对话框。但是现在我需要使用相同的对话框作为菜单单击事件的页面。
尝试这样做时,它会给我这个错误----
core.js:1449 ERROR Error: Uncaught (in promise): Error: StaticInjectorError(AppModule)[CopyImplementDialogComponent -> MatDialogRef]:
StaticInjectorError(Platform: core)[CopyImplementDialogComponent -> MatDialogRef]:
NullInjectorError: No provider for MatDialogRef!
Error: StaticInjectorError(AppModule)[CopyImplementDialogComponent -> MatDialogRef]:
StaticInjectorError(Platform: core)[CopyImplementDialogComponent -> MatDialogRef]:
NullInjectorError: No provider for MatDialogRef!
at _NullInjector.webpackJsonp../node_modules/@angular/core/esm5/core.js._NullInjector.get (core.js:1003)
at resolveToken (core.js:1301)
at tryResolveToken (core.js:1243)
at StaticInjector.webpackJsonp../node_modules/@angular/core/esm5/core.js.StaticInjector.get (core.js:1111)
at resolveToken (core.js:1301)
at tryResolveToken (core.js:1243)
at StaticInjector.webpackJsonp../node_modules/@angular/core/esm5/core.js.StaticInjector.get (core.js:1111)
at resolveNgModuleDep (core.js:10896)
at NgModuleRef_.webpackJsonp../node_modules/@angular/core/esm5/core.js.NgModuleRef_.get (core.js:12129)
at resolveDep (core.js:12619)
at resolvePromise (zone.js:814)
at resolvePromise (zone.js:771)
at zone.js:873
at ZoneDelegate.webpackJsonp../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421)
at Object.onInvokeTask (core.js:4751)
at ZoneDelegate.webpackJsonp../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:420)
at Zone.webpackJsonp../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:188)
at drainMicroTaskQueue (zone.js:595)
这是导航条形码。
{
icon: 'file_copy',
text: 'Copy Implement',
type: NavType.RouterLink,
location: 'copy/implement'
},
这是router.ts
{
path: 'copy/implement',
component: CopyImplementDialogComponent
},
这是我的app.Modeule.ts
import { CopyImplementDialogComponent } from './setup-implement/copy-implement-dialog/copy-implement-dialog.component';
import { MatDialogModule} from '@angular/material';
import { HttpClientModule } from '@angular/common/http'
@NgModule({
entryComponents: [
ImplementStatusModalComponent,
AttachImplementModalComponent,
RemoveImplementModalComponent,
RecordRepairModalComponent,
RecordReplaceModalComponent,
ChangeImplementJobsiteModalComponent,
AddRepairerWorkshopModalComponent,
SchematicViewComponent,
DeleteConfirmationDialogComponent
],
declarations: [
AppComponent,
NavbarTopComponent,
NavbarSide,
BreadCrumbTopComponent,
RedirectComponent,
DashboardComponent,
ImplementDetailsComponent,
ImplementStatusModalComponent,
AttachImplementModalComponent,
RemoveImplementModalComponent,
RecordRepairModalComponent,
RecordReplaceModalComponent,
ChangeImplementJobsiteModalComponent,
RemoveImplementModalComponent,
ImplementTemplateSetupComponent,
AddRepairerWorkshopModalComponent,
FilterPipe,
ImplementTemplatesComponent,
SchematicViewComponent,
CarouselComponent,
CarouselItemDirective,
CarouselItemElement,
SetupEquipmentComponent,
SetupImplementComponent,
ApplySelectionComponent,
DraggableSchematicComponent,
DeleteConfirmationDialogComponent,
PreferencesComponent,
CopyImplementDialogComponent
],
imports: [
routing,
BrowserModule,
HttpModule,
FormsModule,
MaterialModule,
BrowserAnimationsModule,
ReactiveFormsModule,
MatTooltipModule,
MatDialogModule,
HttpClientModule,
ToastModule.forRoot()
],
providers: [
AppService,
ImplementDetailsService,
ChangeImplementJobsiteModalService,
AttachImplementModalService,
RemoveImplementModalService,
ImplementStatusModalService,
InventoryService,
CustomerService,
EquipmentService,
ImplementTemplateService,
UserService,
SchematicViewService,
SetupEquipmentService,
SetupImplementService,
PreferencesService
],
bootstrap: [AppComponent]
})
export class AppModule { }