我们刚刚将应用程序升级到了angular 7,我们注意到所有ngBootstrap模态现在都默认自动关闭按钮,如下图所示。
这是我的代码:
html模态代码:
<form [formGroup]="storeForm" novalidate>
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Modal Test</h4>
<button type="button" class="close" aria-label="Close"
(click)="activeModal.dismiss('Cross click')">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<h4>Todo</h4>
</div>
<div class="modal-footer">
<button role="button" type="submit" class="btn btn-primary"
(click)="activeModal.close('Finish click')" prevent-double-
submit>{{ 'store.add.finish' | translate }}</button>
</div>
</div>
</form>
Run Code Online (Sandbox Code Playgroud)
以及如何通过我的component.ts调用模式
const modal = this._modalService.open(ModalComponent, { backdrop:
'static', size: 'lg'});
modal.result.then(
(data) => {
// some code
},
() => {
}
);
Run Code Online (Sandbox Code Playgroud)
我的问题是如何删除这种不符合我们预期行为的默认自动对焦?
感谢您的阅读,请原谅拼写错误。