将弹出式表单内容保存在ng-bootstrap(Angular 2+)中

时间:2019-01-24 21:58:42

标签: angular bootstrap-4 popover ng-bootstrap ngx-bootstrap

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

如果我单击弹出窗口按钮并在输入字段中键入内容,则当他们关闭弹出窗口时,输入字段将被清除

如果不能使用ng-bootstrap ...可以使用ngx-bootstrap吗?

Demo is here

<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>

1 个答案:

答案 0 :(得分:1)

是的,有可能,我们需要定义一个本地属性,将其用作输入字段的ngModel。这样,它们将被绑在一起,您可以随心所欲地传递该值。

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