Agenda
Given below is the list of content that we are going to cover in this blog.
- Generating our own component using ng generate component ‘name’ in Angular CLI.
- Generating a service and using it to manipulate the data.
- Including bootstrap in our Angular app
Let’s get started.
Angular uses TypeScript as its default scripting language.
First, using the npm, let us generate a component named ‘customer-forms’. If you don’t know what npm is or how to work with npm, I recommend you click here.
It will generate 4 files.

One is page-specific ‘customer-forms.component.css’ file; the second one is ‘customer-forms.component.html’; next is ‘customer-forms.component.spec.ts’ which is a test file to test your code; the last one is ‘customer-forms.component.ts’ which is a TypeScript file.
Add this component to your ‘app.module.ts’ file.
import { BrowserModule } from '@angular/platform-browser';
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule} from '@angular/forms'
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { CustomerFormsComponent } from './customer-forms/customer-forms.component';
import { CustomerViewComponent } from './customer-view/customer-view.component';
@NgModule({
imports: [
BrowserModule,
CommonModule,
AppRoutingModule,
FormsModule,
ReactiveFormsModule
],
declarations: [
// AppComponent,
CustomerFormsComponent,
CustomerViewComponent
],
bootstrap: [
// AppComponent,
CustomerFormsComponent,
CustomerViewComponent
]
})
export class AppModule { }
Now, let’s create a service.ts file for future use.
Type ng generate service ‘name’.
export class CustomerFormsService{
softwareData = [
{Label:'None',Option:[{softwareId:0,SoftwareName:'None'}]},
{Label:'ECommerce',Option:[
{softwareId:1,SoftwareName:'Flipkart'},
{softwareId:2,SoftwareName:'Amazon'}]
},
{Label:'Asset Manager',Option:[
{softwareId:3,SoftwareName:'Asset Management'},
{softwareId:4,SoftwareName:'Barcode Printer'},
{softwareId:5,SoftwareName:'Asset Locator'}]
},
{Label:'School Management',Option:[
{softwareId:6,SoftwareName:'Attendance Management'},
{softwareId:7,SoftwareName:'Exam Management'},
{softwareId:8,SoftwareName:'Faculty Management'},
{softwareId:9,SoftwareName:'Schooling'}]
},
{Label:'Business',Option:[
{softwareId:10,SoftwareName:'Warehouse'},
{softwareId:11,SoftwareName:'Billing'},
{softwareId:12,SoftwareName:'GST filing'}]
}
];
customerRequests = [
{
id: 1,
CompanyName: 'Rohan IT',
Name: 'Rohan Sharma',
SoftwareId: 5,
RelationshipDuration: 10
},
{
id: 2,
CompanyName: 'Infogain IT',
Name: 'Lokesh Sharma',
SoftwareId: 0,
RelationshipDuration: 0
},
{
id: 3,
CompanyName: 'Infozech',
Name: 'Rahul Kumar',
SoftwareId: 9,
RelationshipDuration: 11
}];
getAllSoftware() {
return this.softwareData;
}
get() {
return this.customerRequests;
}
getOne(id: number) {
return this.customerRequests.find( x=> x.id == id );
}
add(customerRequest) {
console.log('In for add');
this.customerRequests.push(customerRequest)
console.log('Added sucessfully');
console.log(this.customerRequests);
}
delete(customerRequest) {
const index = this.customerRequests.indexOf(customerRequest);
if(index == 0)
{
this.customerRequests.splice(index,1);
}
}
} 
Join the conversation! Your thoughts help the community grow.