Angular 2 is the latest framework for building web applications using typescript. Recently, angular team is skipped the version 3.x because, router package is shipped with 3.x previously, so instead of putting into 3.x, choose to move to 4.x.

Wednesday, 9 November 2016

Decorators in Angular 2


Decorators are for meta data.

I will explain you with the sample example.

import { Component } from '@angular/core';
@Component({
         selector: 'my-app',
         template: '<h1>Hello Srinivas Nidadavolu!</h1>'

})
export class MyAppComponent {}
In Html, Just add,
<my-app>Please wait, Loading… </my-app>

How does the html and browser know that, angular is associated with this ?

So, tell the browser, we are using meta data. We attach the meta data using the component decorator.

  • First we import the component
  • Decorator and component are functions, By using the decorators to assign some properties.
  • We are referring <my-app> using component of angular. So, component is a decorator.
Test Your Understanding by answering the below question(Select from multiple choices and get score instantly)
1. Decorator in Angular2 refer to
meta data
class
html tag
Score =
Correct answers:

0 coment�rios:

Post a Comment

Labels

Online Training

Your Name :
Your Email: (required)
Your Message: (required)

Powered by Blogger.

Recent Posts

Find Us On Facebook

Popular Posts