- Get link
- X
- Other Apps
Component
The module is like a container and the component is a small container.
In Angular2, "everything is a component ". The component is the main method we build and specify element and logic on the page, though both custom element and attributes that add functionality to our existing component.
Angular applications are made up of components. A component is the merge of an HTML template and a component class that controls a part of the screen. Every component begins with the @Component decorator function that takes a metadata object. The metadata object report how the HTML templated and component class work together.
We attached @Component, a TypeScript decorator, which allows you to modify a class or function and adds metadata to properties and function arguments.
The component must belong to a NgModule in order for it to be available to another component or application. To construct it a member of an NgModule, list it in the declaration field of the NgModule metadata
import { Component } from '@angular/core';
@Component ({
selector: 'rio-hello',
template: ' <p>Hello, {{name}}!</p>',
})
export class HelloComponent {
name :string;
constructor() {
this.name = 'World';
}
}



Comments
Post a Comment