Reputation: 55
** Cannot read property 'push' of undefined Angular Firebase**
import { Injectable } from '@angular/core';
import {FormControl,FormGroup, Validators} from '@angular/forms';
import {AngularFireDatabase, AngularFireList} from 'angularfire2/database';
@Injectable()
export class QuestionService {
constructor(private firebase: AngularFireDatabase) { }
questionList:AngularFireList<any>;
form = new FormGroup({
$key: new FormControl(null),
newQuestion: new FormControl('', Validators.required)
});
getQuestions(){
this.questionList = this.firebase.list('questions');
return this.questionList.snapshotChanges();
}
insertQuestion(question){
this.questionList.push({
newQuestion: question.newQuestion
});
}
}
Trying to push data to firebase but encountering this error.
Upvotes: 0
Views: 401