3

I'm trying to use angular material to implement an autocomplete but I'm getting the error

ERROR in app.module.ts:22:8 - error TS2306: File '/home/user/MedvibesWebRepo/medvibes/medvibes-web/medvibes/medvibes-main-web/src/main/webapp/node_modules/@angular/material/index.d.ts' is not a module.

22 } from '@angular/material/';
      ~~~~~~~~~~~~~~~~~~~~

index.d.ts only contains comments and I checked app.module.ts's 22nd line and it doesn't contain '@angular/material/'; I don't understand where the 22 } from '@angular/material/'; error comes from? How to fix this issue?

2 Answers 2

3

I think this is related to how to import module from angular/material.

For example: if you want to import MatSliderModule:

for angular 9,

import { MatSliderModule } from '@angular/material/slider';

in angular 8 or below, you can still do

import { MatSliderModule } from '@angular/material';

Sign up to request clarification or add additional context in comments.

2 Comments

but any shortcut for that as if we want import multiple module then how to do that ?
on angular upgrade guild, update.angular.io/#7.0:8.0. if you select I use Angular Material. It says Instead of importing from @angular/material, you should import deeply from the specific component. E.g. @angular/material/button. ng update will do this automatically for you
0

IMHO this is related to the Angular version you are using. for example, if you want to import MatSliderModule, for angular 9:

import { MatSliderModule } from '@angular/material/slider';

for earlier versions, you don't need to specify the exact path:

import { MatSliderModule } from '@angular/material';

will do just fine

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.