Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 类型脚本模式对话框承诺响应_Javascript_Typescript_Promise - Fatal编程技术网

Javascript 类型脚本模式对话框承诺响应

Javascript 类型脚本模式对话框承诺响应,javascript,typescript,promise,Javascript,Typescript,Promise,我的应用程序中有一个显示引导对话框的服务。目前代码非常简单: async showConfirmation(message: string): Promise<boolean> { this.message(message); this.isPopupOpen(true); return false; } 此时,showConfirmation函数立即返回一个硬编码的false,而我想等待用户的响应,并将其作为showConfirmation的结果返回

我的应用程序中有一个显示引导对话框的服务。目前代码非常简单:

async showConfirmation(message: string): Promise<boolean> {

    this.message(message);
    this.isPopupOpen(true);

    return false;
}
此时,
showConfirmation
函数立即返回一个硬编码的
false
,而我想等待用户的响应,并将其作为
showConfirmation
的结果返回


我不完全确定实现这一目标的最佳方法。我如何才能让它等待用户返回相应的响应?

它的可能副本在同一个大概范围内,但在使用TypeScript时不包括这种情况。我仍然在努力找出如何让它工作,即使有其他答案的内容。
<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">&times;</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);
}