Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to include Angular Material in Angular 17?

Angular Material’s documentation says:

import { MatSlideToggleModule } from '@angular/material/slide-toggle';

@NgModule ({
  imports: [
    MatSlideToggleModule,
  ]
})
class AppModule {}

But Angular 17 doesn’t create app.module file by default. Is there any way to do that without app.module?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Angular v17 onwards, standalone is default via CLI

Which means when you create new project it wont have any modules in it

As a workaround it is possible to create a module-based app by using the --no-standalone flag : ng new --no-standalone which will create a app.modules.ts in your project

use this command :

ng new myNewApp --no-standalone

Follow it up with :

ng add @angular/material 

Then import relevent modules from angular material to your project app.module.ts :

import { MatSlideToggleModule } from '@angular/material/slide-toggle';

@NgModule ({
  imports: [
    MatSlideToggleModule,
  ]
})
class AppModule {}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading