简体   繁体   English

我的应用程序似乎没有选择我的 angular 材料/对话框模块。 我该如何解决这个问题以使其正常工作?

[英]My application doesn't seem to picking up my angular material/dialog module. How can i fix this so that it works?

I would like to use two material ui components for my angular application.我想为我的 angular 应用程序使用两个材质 ui 组件。 They are MatDialog , and MatDialogConfig .它们是MatDialogMatDialogConfig I'm not sure if I have something in the wrong place or not but basically all my modules work fine except this one.我不确定我是否在错误的地方放了东西,但基本上我的所有模块都可以正常工作,除了这个。 Both my app.module.ts file and my component course-dialog.component file have import statements with MatDialog , and MatDialogConfig , it's just not finding the module when I run the program.我的app.module.ts文件和我的组件course-dialog.component文件都有带有MatDialogMatDialogConfig的导入语句,只是在我运行程序时找不到模块。 They are listed below.它们在下面列出。 How can I go about getting my compiler to load these modules?我怎样才能让我的编译器加载这些模块? app.module.ts 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 {} }) 导出 class AppModule {}

courses-list.component.ts课程列表.component.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 { }

In your module you need to import the MatDialogModule like so:在您的模块中,您需要像这样导入MatDialogModule

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

The imports that you have in your files are to be used in the components.您在文件中的导入将在组件中使用。

So in your modules you should have this import:所以在你的模块中你应该有这个导入:

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

MatDialog and MatDialogConfig should be imported in the components and not in the modules. MatDialogMatDialogConfig应该在组件中而不是在模块中导入。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 部署 Angular 应用程序在我的服务器上似乎没有做任何事情 - Deploying Angular Application doesn't seem to do anything on my server 为什么我的 angular 应用程序没有选择可动手操作的 css? - Why my angular application is not picking up handsontable css? 如何修复我的对话框 window 不弹出 angular 模态 - How can I fix my dialog window not popping out angular modal 如何等待对话材料响应以继续我的功能? - How can i wait dialog material response to continue my function? 我使用来自 angular/material 的 mat-tabs 但标签没有显示。 我如何更改它以便显示我的标签? - I´m using mat-tabs from angular/material but the Labels aren't shown. How can i change it so my labels are displayed? Angular 7:找不到模块。 无法解决“下划线” - Angular 7: can't find module. can't resolve 'underscore' 我的 angular-material 文本很大,我无法控制它 - My angular-material text is huge and I can't control it 如何将模块添加到我的SystemJs配置文件,以便我可以角度导入它 - How to add a module to my SystemJs config file so I can import it in angular 如何为 Angular Material 2 对话框设置动画? - How can I animate Angular Material 2 dialog? 如何修复我的数据无法从服务中获取到Angular中的模块 - How can I fix my data not getting from service to module in Angular
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM