widness
1/26/2018 - 9:50 PM

String interpolation

export class UserComponent implements OnInit {
  name:string;
  age:number;
  address:Address;
  hobbies:string[];
}

constructor(){
  consol.log('constructor ran..');
}

ngOnInit() {
  consol.log(ngOnInit ran..');
  
  this.name = 'John Doe';
  this.age = 30;
  this.address = {  
    street: '50 Main st',
    city: 'Boston'
  }
  
  this.hobbies = ['Write code', 'watch movies'];
}
{{name}}
{{age}}
{{address.street}} {{address.city}}

<ul>
  *ngFor="let hobby of hobbies; let i = index">{{i + 1}}: {{hobby}}
<ul>