why data cannot insert in firebase? can help me
this from provider.ts
createData(new_data){
return new Promise ((resolve,reject)=>{
var newPostkey = firebase.database().ref().child(‘todolist’).push().key;
firebase.database().ref(‘todolist/’+newPostkey+’/’).set(new_data).then(response=>{
resolve(response);
},err=>{
reject(err);
})
});
}
addpackage.ts
import { Component } from ‘@angular/core’;
import { IonicPage, NavController, NavParams, ViewController } from ‘ionic-angular’;
/**
- Generated class for the AddPackagePage page.
- See https://ionicframework.com/docs/components/#navigation for more info on
- Ionic pages and navigation.
*/
@IonicPage()
@Component({
selector: ‘page-add-package’,
templateUrl: ‘add-package.html’,
})
export class AddPackagePage {
package:any;
price:any;
constructor(public navCtrl: NavController, public navParams: NavParams,
private vc:ViewController) {
}
ionViewDidLoad() {
console.log(‘ionViewDidLoad AddPackagePage’);
}
close(){
this.vc.dismiss(0);
}
BtnSubmit(){
this.vc.dismiss({package:this.package, price:this.price})
}
}
admin.ts
import { Component } from ‘@angular/core’;
import { IonicPage, NavController, NavParams, ModalController } from ‘ionic-angular’;
import { AddPackagePage } from ‘…/add-package/add-package’;
import { FirebaseProvider } from ‘…/…/providers/firebase/firebase’;
/**
- Generated class for the AdminPage page.
- See https://ionicframework.com/docs/components/#navigation for more info on
- Ionic pages and navigation.
*/
@IonicPage()
@Component({
selector: ‘page-admin’,
templateUrl: ‘admin.html’,
})
export class AdminPage {
constructor(public navCtrl: NavController, public navParams: NavParams,
private modal: ModalController, private fb:FirebaseProvider) {
}
ionViewDidLoad() {
console.log(‘ionViewDidLoad AdminPage’);
}
AddToPackage(){
let xyz = this.modal.create(AddPackagePage);
xyz.onDidDismiss(data=>{
if(data==0){
}else{
this.fb.createData(data).then(resp=>{
console.log("data INSERT");
},err=>{
console.log("CANNOT INSERT",err);
})
}
});
xyz.present();
}
}