我的应用程序似乎没有接收到我的angular materialdialog模块。我如何解决这个问题,使其工作?

我想在我的Angular应用中使用两个material ui组件,它们是 MatDialogMatDialogConfig. 我不知道是不是我的东西放错了地方,但基本上我所有的模块都能正常工作,除了这个。我的两个 app.module.ts 文件和我的组件 course-dialog.component 文件中的导入语句带有 MatDialogMatDialogConfig,只是在我运行程序时找不到模块。这些模块列在下面,我怎样才能让我的编译器加载这些模块呢?我怎样才能让我的编译器加载这些模块呢?app.module.ts

 import { NgModule, ErrorHandler } from '@angular/core';
 import { registerLocaleData } from '@angular/common';
 import { HttpClientModule } from '@angular/common/http';
 import { BrowserModule } from '@angular/platform-browser';
 import { RouteReuseStrategy } from '@angular/router';
 import {MatDialog, MatDialogConfig} from '@angular/material/dialog';
 import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
 import { SplashScreen } from '@ionic-native/splash-screen/ngx';
 import { StatusBar } from '@ionic-native/status-bar/ngx';
 import { GooglePlus } from '@ionic-native/google-plus/ngx';
 import { Facebook } from '@ionic-native/facebook/ngx';
 import { StripeModule } from "stripe-angular"
 import { AppComponent } from './app.component';
 import { AppRoutingModule } from './app-routing.module';
 import { AngularFireModule } from '@angular/fire';
 import {AngularFireAuthModule} from '@angular/fire/auth';
 import {AngularFirestoreModule} from '@angular/fire/firestore';
 import {AngularFireStorageModule} from '@angular/fire/storage';
 import { AngularFireDatabaseModule } from '@angular/fire/database';



 /*Services*/
 import { AuthService } from '@services/auth.service';
 import { CallService } from '@services/call.service';
 import { DataProvider } from '@services/data/base.data-provider';
 import { LocalDataProvider } from '@services/data/local.data- 
 provider';
 import { FirebaseDataProvider } from '@services/data/firebase.data- 
 provider';
 import { RemoteDataProvider } from '@services/data/remote.data- 
 provider';
 import { BackendlessDataProvider } from 
'@services/data/backendless.data-provider';
 import { EmailService } from '@services/email.service';
 import { FacebookApiService } from '@services/facebook-api.service';
 import { InAppBrowserService } from '@services/in-app- 
 browser.service';
 import { MapsService } from '@services/maps.service';
 import { OpenHoursService } from '@services/open-hours.service';
 import { FavoritesService } from '@services/favorites.service';

 import { Calendar } from '@ionic-native/calendar/ngx';
 import { EmailComposer } from '@ionic-native/email-composer/ngx';
 import localeDe from '@angular/common/locales/de';
 import { Config } from '../config';
 import { NgxWebstorageModule } from 'ngx-webstorage';
 registerLocaleData(localeDe, 'de');
 import { ComponentsModule } from 
 './pages/components/components.module';
 import { OneSignalModule } from './pages/push/one-signal.module';
 import { AgmCoreModule } from '@agm/core';

 import { ServiceWorkerModule } from '@angular/service-worker';
 import { environment } from '../environments/environment';

 @NgModule({
 declarations: [AppComponent],
  entryComponents: [],
  imports: [
 MatDialog,
 MatDialogConfig,
 HttpClientModule,
  BrowserModule,
  ComponentsModule,
  IonicModule.forRoot(),
   CartServiceModule.forRoot(),
   AppRoutingModule,
   AgmCoreModule.forRoot({
   apiKey: Config.mapsApiKey
    }),
NgxWebstorageModule.forRoot(),
AngularFireModule.initializeApp(Config.firebase),
AngularFireAuthModule,
AngularFirestoreModule,
AngularFireDatabaseModule,
environment.production })
 ],
providers: [
Config,
AuthGuard,

// { provide: ErrorHandler, useClass: IonicErrorHandler },
StatusBar,
{ provide: DataProvider, useClass: LocalDataProvider },
// { provide: DataProvider, useClass: FirebaseDataProvider },
// { provide: DataProvider, useClass: RemoteDataProvider },
// { provide: DataProvider, useClass: BackendlessDataProvider },
EmailService,
CallService,
InAppBrowserService,
MapsService,
OpenHoursService,
FavoritesService,
AuthService,
Calendar,
FacebookApiService,
StatusBar,
OneSignalModule,
SplashScreen,
AuthResolver,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy },
EmailComposer,
GooglePlus,
Facebook
],
bootstrap: [AppComponent]

}) export class AppModule {}

课程列表.组件.ts

 import { AgmCoreModule } from '@agm/core';
 import { CommonModule } from '@angular/common';
 import { NgModule } from '@angular/core';
 import { IonicModule } from '@ionic/angular';
 import { CustomComponentsModule } from '@components/custom- 
 components.module';
 import { DynamicFormModule } from '@components/forms/dynamic- 
 form.module';
 import { PipesModule } from '@pipes/pipes.module';
 import { RouterModule, Routes } from '@angular/router';
 import { CoursesCardListPage } from './courses-card-list.page';
 import {MatDialog, MatDialogConfig} from '@angular/material/dialog';


 const routes: Routes = [
 {
path: '',
component: CoursesCardListPage
}
];


@NgModule({
imports: [MatDialog,MatDialogConfig,IonicModule, CommonModule, 
PipesModule, CustomComponentsModule, RouterModule.forChild(routes)],
declarations: [CoursesCardListPage],
entryComponents: [CoursesCardListPage]
})
export class CoursesCardListModule { }

解决方案:

在你的模块中,你需要导入 MatDialogModule 像这样。

import { MatDialogModule } from '@angular/material/dialog';

你在文件中的导入将被用于组件中。

所以在你的模块中,你应该有这样的导入。

@NgModule({
 declarations: [AppComponent],
  entryComponents: [],
  imports: [
// here is the correct import
 MatDialogModule, // instead of MatDialog and MatDialogConfig
 HttpClientModule,
  BrowserModule,
  ComponentsModule,
....

MatDialogMatDialogConfig 应该在组件中导入,而不是在模块中导入。

给TA打赏
共{{data.count}}人
人已打赏
未分类

概率与z-score的关系,反之亦然。

2022-9-12 12:28:41

未分类

当运行由serverless部署的简单lambda时,无法找到模块 "handler"。

2022-9-12 12:39:35

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索