here I add my service file code.I want to store data in firebase but I can't get data.I got my data in console but get some error & not push in firebase
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import { AngularFireDatabase, AngularFireList } from 'angularfire2/database';
import { Contact } from './logic/contact';
@Injectable({
providedIn: 'root'
})
export class DataService {
list: AngularFireList<any>;
createcontact:Contact = new Contact();
constructor(private firebase:AngularFireDatabase) { }
insertdata(contact: Contact) {
// here I get my data in console
console.log(contact);
this.list.push({
name: contact.name,
email:contact.email,
phoneno:contact.phoneno,
notes:contact.notes,
address:contact.address,
relation:contact.relation
});
}
updatedata(contact: Contact) {
this.list.update(contact._id,{
name: contact.name,
email: contact.email,
phoneno: contact.phoneno,
notes: contact.notes,
address: contact.address,
relation: contact.relation
});
}
}
the error is like
ERROR TypeError: Cannot read property 'push' of undefined