Angular 2Angular2 Databinding


Parent Component : Initialize users lists.

  selector: 'parent-component',
  template: '<div>
                <child-component [users]="users"></child-component>
export class ParentComponent implements OnInit{
  let users : List<User> = null;
  ngOnInit() {
    users.push(new User('A', 'A', '[email protected]');
    users.push(new User('B', 'B', '[email protected]'); 
    users.push(new User('C', 'C', '[email protected]');  

Child component get user from parent component with Input()

selector: 'child-component',
  template: '<div>
                  <table *ngIf="users !== null">
                        <tr *ngFor="let user of users">
export class ChildComponent {
  @Input() users : List<User> = null;

export class User {
  name : string;
  fname : string;
  email : string;

  constructor(_name : string, _fname : string, _email : string){ = _name;
     this.fname = _fname; = _email;