簡體   English   中英

根頁面IONIC2 - ionViewWillEnter()事件

[英]Root Page IONIC2 - ionViewWillEnter() EVENT

我想在我的應用程序中自動登錄,通過從本地檢索值,但我無法做到,它不會給出任何錯誤,也沒有任何錯誤,我無法執行查詢。 請引導我走右門。

```

ionViewWillEnter()   {
      alert("Check Will Enter in Login Page");
      console.log("Login Screen");
    {
      this.database.executeSql("SELECT * FROM user DESC LIMIT 1", []).then((userdata) => {
        {
          let toast = this.toastCtrl.create({
            message: 'User is validated successfully',
            duration: 3000,
            position: 'bottom'
          });

          toast.onDidDismiss(() => {
            console.log('Dismissed toast');
          });

          toast.present();
        }
        this.navCtrl.push(DashboardPage);
         alert("1" + JSON.stringify(userdata));
         alert("Check login_id-" + userdata.rows.item(0).login_id);
         alert("Check password-" + userdata.rows.item(0).password);
        alert("Check password-" + userdata.rows.item(0).mobile_no);
         alert("DeviceID CHECK retrieving from USER" + userdata);

      }, (error) => {
        alert("AUTO LOGIN ERROR" + JSON.stringify(error));

      });
    }
  }

```

您必須在platform.ready()方法中調用SQL執行,如下所示。

 ionViewWillEnter() :void  {

    this.platform.ready().then(() => {
          ///your sql and other code
    })

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM