ionic2模态错误没有数据发送

时间:2017-03-04 10:31:57

标签: mongodb mongoose ionic2

当我使用alertCtrl时,这样的数据会让数据库运行良好。

 addTodo(){

    let prompt = this.alertCtrl.create({
      title: 'add',
      message: 'add',
      inputs: [
        {
          name: 'title'
        },
        {
          name: 'kan'
        },
        {
          name: 'geos'
        },
        {
          name: 'geod'
        },
        {
          name: 'sahip'
        }

      ],
      buttons: [
        {
          text: 'İptal'
        },
        {
          text: 'Kaydet',
          handler: todo => {

                if(todo){

                    this.showLoader();

                    this.todoService.createTodo(todo).then((result) => {
                        this.loading.dismiss();
                        this.todos = result;
                        console.log("todo created");
                    }, (err) => {
                        this.loading.dismiss();
                        console.log("not allowed");
                    });

                }


          }
        }
      ]
    });

    prompt.present();

  }  

但是当我尝试使用modal时,showloader正在运行,但是createtodo无法运行,没有数据可用于db。

 addTodo(){

        let modal = this.modalCtrl.create(KaneklePage);

        modal.onDidDismiss(todo => {

                    if(todo){

                        this.showLoader();

                        this.todoService.createTodo(todo).then((result) => {
                            this.loading.dismiss();
                            this.todos = result;
                            console.log("todo created");
                        }, (err) => {
                            this.loading.dismiss();
                            console.log("not allowed");
                        });

                    }

      });

        modal.present();


  }

这是modalpage

中的解雇代码
save(): void {

    let todo = {
      title: this.title,
      kan: this.kan,
      geos: this.geos,
      geod: this.geod,
      sahip: this.sahip
    };

    this.viewCtrl.dismiss(todo);

  }

0 个答案:

没有答案