Created
December 28, 2017 17:23
-
-
Save crissjm/96e663a1d3ea340e2b91d3f6609cba12 to your computer and use it in GitHub Desktop.
TypeError: Cannot read property ‘uid’ of null
This file contains 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 { NavController, ToastController } from 'ionic-angular'; | |
import { PostFbProvider } from '../../providers/post-fb/post-fb'; | |
import firebase from 'firebase'; | |
import { AddPostPage } from '../add-post/add-post'; | |
@Component({ | |
selector: 'page-home', | |
templateUrl: 'home.html' | |
}) | |
export class HomePage { | |
public post; | |
public uid:any; | |
constructor(public navCtrl: NavController, public toastCtrl: ToastController, private postFB: PostFbProvider) { | |
this.uid = firebase.auth().currentUser.uid; | |
} | |
ionViewDidLoad(){ | |
this.postFB.all().on('value', snapshot => { | |
this.post = []; | |
snapshot.forEach(snap => { | |
this.post.push({ | |
id: snap.key, | |
uid: snap.val().uid, | |
title: snap.val().title, | |
body: snap.val().body | |
}); | |
return false; | |
}) | |
}) | |
} | |
newPost(){ | |
this.navCtrl.push(AddPostPage); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment