首页 > 解决方案 > 在 ng-bootstrap (Angular 2+) 中保存弹出表单内容

问题描述

是否可以在弹出窗口中输入并保留字段值?

如果我单击弹出框按钮并在输入字段中键入,则在关闭弹出框时输入字段将被清除

如果 ng-bootstrap 无法使用...它可以与 ngx-bootstrap 一起使用吗?

演示在这里

<ng-template #popContent>
  Hello, <b>{{name}}</b>!
  <input type="text">
</ng-template>
<ng-template #popTitle>
    Fancy <b>content!!</b>
</ng-template>
<div style="text-align:center">
  <button type="button" class="btn btn-outline-secondary" [ngbPopover]="popContent" [autoClose]="'outside'" [popoverTitle]="popTitle">
    I've got an input field!
  </button>
</div>

标签: angularbootstrap-4popoverng-bootstrapngx-bootstrap

解决方案


是的,有可能,我们需要定义一个本地属性,用作输入字段的 ngModel。通过这种方式,它们将被捆绑在一起,您可以以任何您想要的方式传递该值。

https://stackblitz.com/edit/angular-fyhdcf-ukrs4a


推荐阅读