Created
July 12, 2017 20:47
-
-
Save harrylincoln/111422208a3f8a3ae5f2a8e0b5dab158 to your computer and use it in GitHub Desktop.
Component with focus on the constructor
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
import { Component } from '@angular/core'; | |
import { AngularFireDatabase, FirebaseListObservable } from 'angularfire2/database'; | |
import { AF } from '../providers/af'; | |
import { HttpModule } from '@angular/http'; | |
import { Observable } from 'rxjs/Observable'; | |
import { AngularFireAuthModule, AngularFireAuth } from 'angularfire2/auth'; | |
@Component({ | |
selector: 'app-root', | |
templateUrl: './app.component.html', | |
styleUrls: ['./app.component.css'] | |
}) | |
export class AppComponent { | |
public items: FirebaseListObservable<any[]>; | |
public user: FirebaseListObservable<any>; | |
constructor(db: AngularFireDatabase, public afService: AF, public afAuth: AngularFireAuth) { | |
this.afAuth.authState.subscribe(res => { | |
if (res && res.uid) { | |
this.user = db.list('users/' + res.uid); | |
} | |
}); | |
} ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment