Here is your component, with a timeout to setup the customer in order to 
simulate an async process :
import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-mycomponent',
  templateUrl: './mycomponent.component.html',
  styleUrls: ['./mycomponent.component.css']
})
export class MycomponentComponent implements OnInit {

  customer: any;

  constructor() { }

  ngOnInit() {

    setTimeout(()=> {
      this.customer = {
        name: 'Bob',
        age: 25
      }
    }, 1000);

  }
}

And here is the HTML template of the component :
<p>
  mycomponent works!
</p>
<ul>
  <li>name : {{customer?.name}}</li>
  <li>Age : {{customer?.age}}</li>
</ul>


Try to delete the ? of the elvis operator in the template : you get an 
error message.

This is all what you need. Isn't it great ?!

Cheers

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/angular/9b491c7c-b5d6-4d73-b997-237b96dd7c73%40googlegroups.com.

Reply via email to