javascript - TypeScript 模态对话框承诺响应
问题描述
我的应用程序中有一个显示引导对话框的服务。目前代码非常简单:
async showConfirmation(message: string): Promise<boolean> {
this.message(message);
this.isPopupOpen(true);
return false;
}
目前,对话框 HTML 如下所示:
<div role="dialog" aria-hidden="true" class="modal fade" data-bind="modal: { show: isPopupOpen }">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" title="Close" aria-label="Close">×</button>
<h4 class="modal-title">My Modal</h4>
</div>
<div class="modal-body" data-bind="text: message"></div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" data-bind="click: close">Cancel</button>
<button type="button" class="btn btn-primary" data-dismiss="modal" data-bind="click: close">OK</button>
</div>
</div>
</div>
</div>
我的视图模型中的关闭处理程序也很简单,像这样:
close(data, event) {
//console.debug(data);
console.debug(event.target);
this.isPopupOpen(false);
}
目前该showConfirmation
函数立即返回一个硬编码false
,而我想等待用户响应并将其作为showConfirmation
.
我不完全确定实现这一目标的最佳方法。我怎样才能让它等待用户以返回适当的响应?
解决方案
推荐阅读
- gremlin - 是否有 Gremlin NULL 关键字或类似的不是遍历步骤的东西?
- java - 如何在定义的持续时间后停止执行 Java 中的步骤
- aws-lambda - 调用 lambda 函数处理程序 java
- jenkins - Bitbucket cloud webhook 不触发 Jenkins Build:无分支信息
- r - 如何在年龄金字塔图中填写缺失的年龄?
- python - 如何从 column_name != some_value 的数据库中查找记录?
- python - If 语句简单
- types - 给定一个类型,如何找到我需要实现的所有功能
- javascript - 类型错误:createTestCafe 不是函数
- r - 如何在不增加 NA 的情况下排除纵向分析中的某些参与者