Components in Angular 2

,



The core concept of Angular 2 is component. The whole angular application can be modeled as tree of these component.

The component mean:

A component controls a patch of screen real estate that we could call a view, and declares reusable UI building blocks for an application.

Creating Components

The Component below will interpolate the value of name variable into the template between the double braces {{name}}, what get rendered in the view is <p>Hello World</p>.

import { Component } from '@angular/core';

@Component({
  selector: 'hello',
  template: '<p>Hello, {{name}}!</p>',
})
export class HelloComponent {
  name: string;

  constructor() {
    this.name = 'World';
  }
}





Related Post


Latest Post


Recent Posts Widget

Make sure to never miss a thing...

Get the latest news from the creative industry along with other creative goodies, conveniently delivered to social media.