1
votes

I am importing material modules as follow in app module:

import { NgModule } from '@angular/core';
import { SharedModule } from 'app/shared/shared.module';
import { AppRoutingModule } from './app-routing.module';
import {
  MdTooltipModule,
  MdTabsModule,
  MdSlideToggleModule,
  MdIconModule,
  MdDialogModule,
  MdButtonModule,
  MdListModule,
  MdCardModule,
  MdToolbarModule,
  MdProgressSpinnerModule,
  MdProgressBarModule,
} from '@angular/material';


@NgModule({    
  declarations: [
    //..components
  ],
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
 MdTooltipModule,
  MdTabsModule,
  MdSlideToggleModule,
  MdIconModule,
  MdDialogModule,
  MdButtonModule,
  MdListModule,
  MdCardModule,
  MdToolbarModule,
  MdProgressSpinnerModule,
  MdProgressBarModule,

    SharedModule,
    AppRoutingModule,
  ],
  providers: [
    //..
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }

This gives an error as follow for each Md Module. I also updated my Angular CLI and Material design. I also tried to import only MaterialModule, but it is deprecated.

ERROR in Unexpected value 'MdTooltipModule in E:/Code/employee-web/node_modules/@angular/material/typings/index.d.ts' impor ted by the module 'AppModule in E:/Code/employee-web/src/app/app.module.ts'. Please add a @NgModule annotation.

How can I get rid of this?

2
have you imported ngModule? - Vikhyath Maiya
@Vikhyath Maiya already imported as import { NgModule } from '@angular/core'; - Er Sushil
then post the exact code..Its not there in the code you posted - Vikhyath Maiya
@VikhyathMaiya check post is edited - Er Sushil
which version of angular are you using ? 2.x or 4.x? - Vikhyath Maiya

2 Answers

0
votes

you can still use

import {MaterialModule, MdNativeDateModule, MdButtonModule} from '@angular/material';

it may say MaterialModule is depricated but you dont get any errors. it works fine.

you can import all these extras modules in the shared module and add them in both imports and exports. and only import shared module in the app module and other feature modules. it works fine.

0
votes

The error says there is not module called MdTooltipModule in the module you imported. That means in '@angular/material', there is not MdTooltipModule module.

look into that folder inside your imported package atnode_modules folder and findout that package is part of all the exported modules

i think there might be a spelling mistake

one more think I see is you imported both MdTooltipModule and MdToolbarModule. make sure all youare importing exist inside the module