Skip to content

Instantly share code, notes, and snippets.

@harrylincoln
Last active July 12, 2017 20:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harrylincoln/cdbc755592db032d374758f7298d5d8c to your computer and use it in GitHub Desktop.
Save harrylincoln/cdbc755592db032d374758f7298d5d8c to your computer and use it in GitHub Desktop.
Extended component with createNewUser function
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);
}
});
}
createNewUserHit(event) {
event.preventDefault();
this.afService.createNewUser('testy@testy.com', 'aSaf3rp@a55word!')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment