Anthony Horner
asked on
Angular - adding a material.module.ts to build
I would like to add the Material Design Components to my angular 9 project to make my life a bit easier.
I added it to my application and then got the following as an error for some existing code (when I realised I had to install @angular/material)
I looked around, and found the following
https://stackoverflow.com/ questions/ 58594311/a ngular-mat erial-inde x-d-ts-is- not-a-modu le
So it seems that adding angular material to angular 9 has had issues. I tried to follow what the person with the most upvotes had done, but I don't know how he has integrated material.module.ts into the project.
I created a file in the source folder called material.module.ts with the contents he posted and then referenced this in the app.module.ts. However this came back with the following:
What do I do to integrate this file into my application, do I have to generate a component or do I have to add a decorator (what's that?)
Thanks
I added it to my application and then got the following as an error for some existing code (when I realised I had to install @angular/material)
ERROR in src/app/app.module.ts:4:81 - error TS2306: File 'C:/Workspace/....../node_modules/@angular/material/index.d.ts' is not a module.
4 import { MatInputModule, MatButtonModule, MatSelectModule, MatIconModule } from '[b]@angular/material[/b]';
I looked around, and found the following
https://stackoverflow.com/
So it seems that adding angular material to angular 9 has had issues. I tried to follow what the person with the most upvotes had done, but I don't know how he has integrated material.module.ts into the project.
I created a file in the source folder called material.module.ts with the contents he posted and then referenced this in the app.module.ts. However this came back with the following:
ERROR in src/app/app.module.ts:49:5 - error NG6001: The class 'MaterialModule' is listed in the declarations of the NgModule 'AppModule', but is not a directive, a component, or a pipe. Either remove it from the NgModule's declarations, or add an appropriate Angular decorator.
49 MaterialModule
~~~~~~~~~~~~~~
src/app/material.module.ts:115:14
115 export class MaterialModule {
~~~~~~~~~~~~~~
'MaterialModule' is declared here.
What do I do to integrate this file into my application, do I have to generate a component or do I have to add a decorator (what's that?)
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
material vs bootstrap comes down to how you want your app to look and behave.
Material is more like a framework than Bootstrap Bootstrap is primarily a stylesheet - with some components added on. Material Design is a look and functionality toolkit that is richer than Bootstrap and produces a look and feel (especially on mobile) that has become a standard.
The SO article is quite clear - what they are saying is that you don't do a blanket include of Material into your project - you need to include the different components individually - for each component you want to use.
Material is more like a framework than Bootstrap Bootstrap is primarily a stylesheet - with some components added on. Material Design is a look and functionality toolkit that is richer than Bootstrap and produces a look and feel (especially on mobile) that has become a standard.
The SO article is quite clear - what they are saying is that you don't do a blanket include of Material into your project - you need to include the different components individually - for each component you want to use.
ASKER