Angular 2 Component
Angular 2 application uses the component pattern. It allow us to breakdown the project/product into well defined discrete smaller components. For example smart phone battery is component of a smart phone. In software development we can say that components are logical units that can be combined in a specific way(interfaces) to build large application. Components are basic building block of an angular 2 application. Furthermore we bundle/combine these components through angular module. At high level we can say that to develop angular application you
1. create the component
2. bundle them into module
3. bootstrap your application
1. create the component
2. bundle them into module
3. bootstrap your application
Component = Template (View Layout Angularized HTML) + Class (Data + Behavior) + Metadata (Defined with angular decorator)
Here is the example code link
In the example code above we will focus only on app.component.ts
Class:
Right now for simplicity it only has one property as “name”.
1
2
3
4
5
6
| export class AppComponent { name:string; constructor() { this .name = 'Angular2 Component' } } |
Metadata and angularized html tempalate:
In this example we are using inline HTML Template with interpolation binding feature of Angular 2 {{name}}
1
2
3
4
5
6
7
8
| @Component({ selector: 'my-app' , template: ` <div> <h2>This is my first {{name}}</h2> </div> `, }) |
Decorator is function that adds metadata to class, its members or its methods arguments
Decorator start with @ sign.
Angular do provide built in decorators.
@Component is angular 2 built in decorator that takes an object as parameters. You can say angular 2 decorator are similar to C# class attribute. Also notice that there is no comma after @Component({})
Decorator start with @ sign.
Angular do provide built in decorators.
@Component is angular 2 built in decorator that takes an object as parameters. You can say angular 2 decorator are similar to C# class attribute. Also notice that there is no comma after @Component({})
Import:
1
| import {Component} from '@angular/core' ; |
We import what we need using import statment.
Hope it help to understand angular 2 component.
ReplyDeleteJust wish to say your article is as astounding. The clearness in your
submit is just excellent and i can suppose you’re knowledgeable in this subject.
Well along with your permission allow me to take hold of your RSS feed to stay up
to date with drawing close post. Thanks a million and
please carry on the rewarding work.
Also See: AngularJS Training in Chennai
Pretty informed post! I'm seeking for some topics I need to see that our site affection and then drove it our site all report is really good.If You Learn for Angular JS (or) Big Data Further Details : - Java Training in Chennai | Java Training
ReplyDeletenice information
ReplyDeletehttp://www.kitsonlinetrainings.com/abinitio-online-training.html
http://www.kitsonlinetrainings.com/oracle-bpm-online-training.html
I am newbie to this topic, learned many new updates.
ReplyDeleteSelenium Training in Chennai
Selenium Course in Chennai
iOS Course in Chennai
J2EE Training in Chennai
French Classes in Chennai
web designing training in chennai
best big data training in chennai
perde modelleri
ReplyDeleteSms Onay
Mobil ödeme bozdurma
nft nasıl alınır
ankara evden eve nakliyat
trafik sigortası
DEDEKTÖR
Kurma Web Sitesi
aşk kitapları
SMM PANEL
ReplyDeleteSmm Panel
iş ilanları
İnstagram Takipçi Satın Al
hirdavatciburada.com
beyazesyateknikservisi.com.tr
servis
tiktok jeton hilesi