Created
August 27, 2018 19:44
-
-
Save zoonderkins/ac720ffd1e7a7e60e10a581971f5a81b to your computer and use it in GitHub Desktop.
angular4-mosh-firebase-10&11-angular6-angularfire2v5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //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