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 a view which is a simple HTML page for creating a user interface. The class nothing but codes which support view and is created by TypeScript. Like any other program language, the 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

An IT professional with over 13 years of experience in the full software development life cycle for Windows, services, and web-based applications using Microsoft .NET technologies. Demonstrated expertise in delivering all phases of project development—from initiation to closure—while aligning with business objectives to drive process improvements, competitive advantage, and measurable bottom-line gains. Proven ability to work independently and manage multiple projects successfully. Committed to the efficient and effective development of projects in fast-paced, deadline-driven environments. Skills: Proficient in designing and developing applications using various Microsoft technologies. Total IT Experience: 13+ years

Previous Post Next Post

نموذج الاتصال