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?
>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 {}