Generating a New Component
Showcase how to use Angular CLI to generate a new component and include it in the application module.
ng generate component my-new-component
This command uses the Angular CLI to generate a new component named 'my-new-component'. It creates a new directory with all the component files and updates the module files to declare the new component.
import { MyNewComponent } from './my-new-component/my-new-component.component';
@NgModule({
declarations: [
// ... other components
MyNewComponent
],
// ...
})
export class AppModule { }
When the Angular CLI generates the new component, it typically updates the application module to include the new component in the `declarations` array. This code shows how to manually add the imported `MyNewComponent` to the declarations in `AppModule` in case it needs to be done manually.