NetanelBasal
12/21/2016 - 9:45 AM

ap3.ts

@Component({
  selector: 'my-app',
  template: `
    <button (click)="show = true">Show</button>
    <div>
      <p>{{ person?.id }}</p>
      <p>{{ person?.title }}</p>
      <p>{{ person?.body }}</p>
    </div>
    
    <p *ngIf="show">{{ person?.userId  }}</p>
  `,
})
export class App {
  constructor(public http: Http) {
    this.http.get('https://jsonplaceholder.typicode.com/posts/1')
     .map(res => res.json()).subscribe(res => {
        this.person = res;
     });    
  }
}