Angular 离子2警报问题

Angular 离子2警报问题,angular,alert,ionic2,Angular,Alert,Ionic2,我对基本警报有一个小问题。这是我的设想。 ->我单击页面上的“提交”按钮,如果没有返回任何记录,它将给我一条警告消息。我单击“确定”以排除该问题。-很好。 ->我第二次重复相同的场景,提供无效的输入,这样我就不会恢复记录,应用程序再次向我发出相同的警报。我单击“确定”以解除警报--不工作。 有人能帮上忙吗?? 以下是我获取记录的代码: fetchGroupMembers(form) { //referring this to obj because scope of this is co

我对基本警报有一个小问题。这是我的设想。 ->我单击页面上的“提交”按钮,如果没有返回任何记录,它将给我一条警告消息。我单击“确定”以排除该问题。-很好。 ->我第二次重复相同的场景,提供无效的输入,这样我就不会恢复记录,应用程序再次向我发出相同的警报。我单击“确定”以解除警报--不工作。 有人能帮上忙吗?? 以下是我获取记录的代码:

fetchGroupMembers(form) {
    //referring this to obj because scope of this is confusing in callback functions
    var obj = this;
    //creating loader
    let loading = Loading.create({
      content: "Please wait...",
    });
    //Showing loader on current screen
    obj.nav.present(loading);
    //Send message to server to fetch the group members
    obj.myGlobals.socket.emit('fetchGroupMembers', { groupCode: form.controls['groupCode'].value });
    obj.myGlobals.socket.on('groupMembers', function (result) {
      while (obj.students.pop()); //removing all elements from array of students
      //fetching each record and creating student
      result.forEach(function (record) {
        obj.students.push(new Student(record));
      });
      //on successfull fetch dismiss the loader
      loading.dismiss();
      if (obj.students.length > 0) {
        //set students to global
        obj.myGlobals.students = obj.students
        //navigating to next page with parameters
        obj.nav.push(HostPage, {
          Students: obj.students
        });
        console.log(obj.nav);
      } else {
        //creating alert  
        obj.doAlert();
      }
    });

  }
  doAlert() {
    let alert = Alert.create({
      title: 'No Student Found!!',
      subTitle: "Please check group code. can't find students!!",
      buttons: ['OK']
    });
    this.nav.present(alert);
  }
}
如果我按一下按钮调用doAlert()。它很有魅力。我不明白为什么它在我的场景中不起作用。 任何帮助都将不胜感激。
谢谢,

正如Alert类文档中所讨论的,正确的方法是等待Alert.Disclease()调用返回承诺以解决:

public TEST = () => {
    let alert1 : Alert = Alert.create({
    title: 'Prompt 1',
    message: "First",
    buttons: [{
      text : 'OK',
      handler : () => {
        console.log("First OK");
        alert1.dismiss().then(() => { // wait for the previous transition to finish or the following alert will malfunction
          let alert2 : Alert = Alert.create({
            title   : 'Prompt 2',
            message : "Second",
            buttons : [{
              text    : 'OK',
              handler : () => {
                console.log("Second OK");
                alert2.dismiss(); // DISMISSING MANUALLY
              }
            }]
          });
          this.nav.present(alert2);
        });
      }
    }]
  });
  this.nav.present(alert1);
};

您可以创建一个演示plunker,让我们看看发生了什么吗?我真的不知道如何为分布式代码创建plunker(客户端服务器和服务器再次连接到mLab DB)。似乎我遇到了一个类似的问题:第一个弹出窗口工作正常,第二个弹出窗口无法关闭。提交了一个问题:Plunker here:@BajinderBudhwar:Ionic bug报告模板有一个到Ionic Plunker模板的便捷链接,即使您不想提交Ionic bug,也可以使用该模板。完美的示例。。!!非常感谢你的帮助。。thanks@BajinderBudhwar我很高兴这有帮助。如果你能投赞成票并接受答案,我们将不胜感激:)在爱奥尼亚2.中不起作用。。有什么想法吗?它给了我
Uncaught(承诺):找不到removeView
Sorry@Bla。。。我不再参与这个项目了