Overview Of Angular5 Components


Introduction

In this blog we are going to discuss about the basic components of Angular5, structure of component and will demonstrate to create custom component.

Getting Started

Angular components are the basic building blocks of Angular5 app, it reside within the /src/app folder. Angular5 components consists a component decorator, which includes properties that allow you to define the template, CSS styling, animations, etc.. and a class, which is where your component logic is stored. It also contains any necessary imports like metadata needed by the component.




The template in components represents view which is simple HTML page for creating user interface. The class nothing but codes which supports view and is created by TypeScript. Like any other program language, class also contains data property and methods.

Metadata contains information about classes, it decides whether a class is a component or regular class and is defined by decorated. A decorator is a function which provides information about the classes attached to it. Below code is the example of basic component of Angular5.

 import { Component } from '@angular/core';  
 @Component({  
  selector: 'app-root',  
  templateUrl: './app.component.html',  
  styleUrls: ['./app.component.scss']  
 })  
 export class AppComponent {  
  title = 'app';  
 }  
Custom components can be created in Angular5, the below command line is the example of creating component in Angular CLI.
 $ ng generate component ComponentName  
 $ ng g c ComponentName  

Thanks
Kailash Chandra Behera


1 comment:

  1. jeetwin - Casino Review 2021
    Review of dafabet the jeetwin online casino in 2021. and a detailed review of their jeetwin site. 1xbet Casino has a wide range of games and an awesome jackpot

    ReplyDelete