@MengenL wrote:
The this.ref.push in not working, can anyone please help?
Any help will be appreciatedexport class ProfilePage implements OnInit {
data: Observable<any>;
ref: AngularFireList;months = [
{value: 0, name: ‘January’},
{value: 1, name: ‘February’},
{value: 2, name: ‘March’},
{value: 3, name: ‘April’},
{value: 4, name: ‘May’},
{value: 5, name: ‘June’},
{value: 6, name: ‘July’},
{value: 7, name: ‘August’},
{value: 8, name: ‘September’},
{value: 9, name: ‘October’},
{value: 10, name: ‘November’},
{value: 11, name: ‘December’},
];transaction = {
value: 0,
expense: false,
month: 0,
}@ViewChild(‘valueBarsCanvas’, {static: false}) valueBarCanvas;
valueBarsChart: any;
chartData: any; /**suppose to be null */constructor(private afs: AngularFirestore, private user: UserService, public NavCtrl: NavController, private db: AngularFireDatabase, private toastCtrl: ToastController, public toastcontroller: ToastController) {
}async ionViewDidLoad() {
this.ref = this.db.list(‘transactions’, ref => ref.orderByChild(‘month’));
this.ref.valueChanges().subscribe(result => {
if (this.chartData) {
this.updateCharts(result);
}
else {
this.createCharts(result);
}
});
}async addTransaction() {
this.ref.push(this.transaction).then(() => {
this.transaction = {
value: 0,
expense: false,
month: 0,
};The console shows:
ERROR Error: Uncaught (in promise): TypeError: Cannot read property ‘push’ of undefined
Posts: 1
Participants: 1