title: Typescript - set data from Observable to an attribute
body: <p>I'm trying to extract data from an Observable result from AngularFireDatabase.object() call and set it to an attribute to use it later in others scopes.</p>
  
  <pre><code>export class QuizzEditComponent implements OnInit {
    private quizzRef: any;
    private quizzObject: any;
    private key: string;
  
    constructor(private router: ActivatedRoute, private database: AngularFireDatabase) {
      this.key = this.router.snapshot.paramMap.get('id');
      this.quizzRef = this.database.object(environment.firebase.databaseName+'/'+this.key);
      this.quizzRef.valueChanges().forEach(line =&gt; {
        this.quizzObject = line;
        console.log(this.quizzObject); // this display the wanted object
      });
      console.log(this.quizzObject); // This display undefined
    }
  }
  </code></pre>
  
  <p>I tried different iteration like <code>for let line of this.quizzItem</code> doesn't work since Observable is an object !</p>
  
  <p>Any ideas !</p>