Angular 2.0 Components - Part 2

Templates

define a component's view or HTML content for the component.In template there are two type define template
  • in-line template

  • template URL command

This is how it work

Metadata

Metadata defines the way to process a class. We can define the metadata by using decorator.

The @Component decorator, which identifies the class immediately below it as a component class.If the “Component” is not defined, then Type Script treats this as a simple class.

Data binding

Used to bind the data between view and business logic.
In angular 2.0 there are four forms of data binding. As a summary of data binding.

Directives

Used to extend HTML attributes and provide some special behaviors to HTML DOM elements.A directive is a class with a @Directive decorator.

There are two type of Directives
  • structural directives : alter layout by adding, removing, and replacing elements in DOM
  • Attribute directives : alter the appearance or behavior of an existing element.
And also angular provides write own directives call custom directive.

Services

A service is typically a class with a narrow, well-defined purpose.Those services available to components through dependency injection.Services are injected into application using dependency injection mechanism.

Dependency Injections

Mechanism to pass an object as a dependency in a different component. Most dependencies are services.
constructor(private service: UserService) { }

End of Angular 2.0 Components, so next article will be simple application development step by step.

Comments

Popular posts from this blog

Gulp Part 01

Basic concepts of Blockchain