我有两种警报 - 辅助警报和延迟警报
首先显示辅助警报消息,用户必须单击“确定”按钮才能将其关闭。
但也有延迟警报......这是由setTimeout()
当向用户显示此延迟警报时,我尝试自动关闭辅助警报
我试图像这样消除次要警报
this.secondaryAlertVar.dismiss();
但这不起作用。
这是代码
import { Component, OnInit } from "@angular/core";
import * as dialogs from "tns-core-modules/ui/dialogs";
@Component({
selector: "Home",
moduleId: module.id,
templateUrl: "./home.component.html",
styleUrls: ['./home.component.css']
})
export class HomeComponent implements OnInit {
secondaryAlertVar: any;
constructor() {
this.secondaryAlerts(function () { }, 0, "Hhmm... ", "Alert");
setTimeout(() => {
this.delayedAlertBox("All other alerts should close automatically when this triggered");
}, 10000);
}
ngOnInit() {
}
secondaryAlerts(callback, mode, message, title): any {
this.secondaryAlertVar = dialogs
.alert({
title: title,
message: message,
cancelable: false,
okButtonText: "OK"
})
.then(callback);
}
delayedAlertBox(message) {
this.secondaryAlertVar.dismiss();
var options = {
title: "Delayed Alert",
message: message,
okButtonText: "Ok",
cancelable: false,
};
dialogs.alert(options).then(() => {
});
}
}