Please enable Javascript for better experience...
Creating Component in Angular 8
By Rahul Kumar Jha | Nov 22, 2019 | In Tutorials | Update: May 30, 2021 | Total Views [ 4023 ]
Taged In
(1 Like)
Rate

In last section of tutorial we learnt setting up angular 8 environment to create first angular project. In this tutorial we will learn about component in angular and see steps to generate a component.

Introduction

In this tutorial we will see overview of folder structure of angular 8 application. Later we will see the different ways to create a component.

Project structure

Angular project has following structure. It has e2e folder which is used for writing test, node_module contains pre-defined plugins, src folder which has all the code related to project.

folder structure

Creating Component

Now let's add component. You can add new component by right clicking manually on src folder and adding folder, component, style, test one by one.

manually creating

You can also open terminal or command prompt to generate component automatically.

terminal

You can use below command to generate a component. It will generate component.ts, component.html, component.css and component.spec.ts files.

generating component

You can also use below short command to generate component where "g" stands for generate and "c" stands for component.

short cut command

If you want to ignore spec and style files during component generation, you can use "--skipTest" to skip spec file and "-is" to skip style file. to skip test now please use "--skip-tests" instead of "--skipTests"

customizing component

Hope this helps you.
<< Step-By-Step Angular 8 app setup

Share this

About the Author

Rahul Kumar Jha
Rahul Kumar Jha
Founder, Developer dotnet-concept.com

Public profile: user/profile/99900001


Has working experience in different phases of Software Development Life Cycle (SDLC) in CMS, Gaming, Health Care and Financial Services domain using Agile pattern. Working experience in Design patterns, ASP.NET, MVC, ANGULAR, ANGULAR JS, Windows application, WCF, ADO.NET, SQL Server and Test Driven Development (TDD) environment with JQuery, JavaScript, N-Unit, Entity Frameworks, LINQ, Code Refactoring and Business Objects Models.

User's Comments


 
Please SignUp/Login to comment...

Or comment as anonymous...
* Name
* Email ID
Comment
 
 
 
 
 
 
Sponsors