Thursday, 27 December 2018

How to generate a component using Angular CLI?

To generate a component using the Angular CLI command:

ng generate component Employee

OR

ng g c Employee

When we create an Employee component using angular CLI  it will create a folder employee inside the app folder and inside the employee folder, it will create below files.

employee.component.css
employee.component.html
employee.component.spec.ts
employee.component.ts

If you will check app.module.ts you will see all the information related to employee component is registered.

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { EmployeeComponent } from './employee/employee.component';

@NgModule({
declarations: [
AppComponent,
EmployeeComponent
],
imports: [
BrowserModule,
AppRoutingModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { } 

No comments:

Post a Comment