generate component in angular ng g c popular Use the Angular CLI to generate a new component named pakainfo_v1.
generate component in angular
Create New App:
ng new pakainfo_v1
generate new component using following command:
ng g c popular
generate new component in angular 8 app
popular.component.html
You can write HTML source code:
<p>popular works!</p>
popular.component.css
You can write style or CSS code:
p{ color:green }
popular.component.ts
import { Component, OnInit } from '@angular/core'; @Component({ selector: 'app-popular', templateUrl: './popular.component.html', styleUrls: ['./popular.component.css'] }) export class PopularComponent implements OnInit { constructor() { } ngOnInit() { } }
Don’t Miss : Angular 6 Tutorial with Examples
popular.component.spec.ts
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { PopularComponent } from './popular.component'; describe('PopularComponent', () => { let component: PopularComponent; let fixture: ComponentFixture; beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [ PopularComponent ] }) .compileComponents(); })); beforeEach(() => { fixture = TestBed.createComponent(PopularComponent); component = fixture.componentInstance; fixture.detectChanges(); }); it('should create', () => { expect(component).toBeTruthy(); }); });
I hope you get an idea about generate component in angular.
I would like to have feedback on my infinityknow.com.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.
I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I’m a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.