Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70435

Cannot insert data to firebase

$
0
0

@ariff23 wrote:

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’;

/**

@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’;

/**

@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();

}

}

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70435

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>