Inputs in Angular 2

Inputs helps pass the data dynamically to the component. There are situations where you pass data to component and in turn component would invoke the service and fetch the desired result.Inputs are ideally suitable for such situation.

Defining Inputs in Component :

  1. @Input  directive in the Component which is imported from angular2/core.
  2. Defining Inputs in Component MetaData.

Example  of Inputs with directive:

import {Component,Input} from 'angular2/core'



'template':"<span>{{Name}} </span>"


export class InputsampleComponent


@Input Name ;


Using  Input in Root/App Component :

<inputsample [Name ]="somename"> </inputsample>

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s