Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save zoonderkins/ac720ffd1e7a7e60e10a581971f5a81b to your computer and use it in GitHub Desktop.
Save zoonderkins/ac720ffd1e7a7e60e10a581971f5a81b to your computer and use it in GitHub Desktop.
angular4-mosh-firebase-10&11-angular6-angularfire2v5
//app.component.html
<ul>
<li *ngFor="let course of (courses$ | async)">
{{course}}
</li>
</ul>
<p>
{{ (course$ | async | json) }}
</p>
// app.component.ts
import { Component, OnDestroy } from '@angular/core';
import {AngularFireDatabase} from 'angularfire2/database'
import { Observable } from 'rxjs';
export class AppComponent {
courses$;
course$;
constructor(db: AngularFireDatabase) {
this.courses$ = db.list(`/courses`).valueChanges()
this.course$ = db.object(`/courses/1`).valueChanges()
}
}
// Things fixed for more details: https://stackoverflow.com/a/50884243/4356464
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment