Component !!!

Hello & welcome to all Computer & IT fellows! I am Jinal Shah, an Engineer, a Teacher & more over a Coder for all the time.

Today in this Tutorial I am going to show & explain all about what is “COMPONENT”? & how it is created. Well let me tell you the fact that, COMPONENT is the most important Part/Thing in angular2 because of its reuse ability.

Generally component is consist of html (metadata), type script and directives. The work of Scope, directives and controller in Angular 1.0 is totally done by component of angular 2.0. According to my Guru Mr. Dhananjay Kumar component are

component

Here in this tutorial; I am using the command line interface, to have work convenience with Angular 2.0. As the reason is quite simple that when we are adding the component through the command line it will automatically add the component.html, component.cs, and also css file for us. Don’t you think it is much better then adding the typescript and html and css and libraries files manually?

Here is the command to ADD component to your existing project. Project directory structure before adding demo.

directory

cmd> ng g c demo

Here, ng stands for angular, g stands for generate, c stands for component.so it is ng generate component name of the component.

Hence it will create the demo directory inside the app directory.

dirc.PNG

Now, suppose that if we want to add new component inside the demo directory without creating the new directory. So I will just type the command as

cmd>ng g c otherdemo -flat

other.PNG

we can decorate the component in two ways.

1)Inline and 2) External..

I will show you both the ways in my next Article.

Hope it will be helpful to you and also you can give your feedback & stay tuned for more update for angular2 demos.

cheers!!!!

1

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s