小编Flo*_*low的帖子

Angular7和NgbModal:如何删除默认的自动对焦

我们刚刚将应用程序升级到了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">&times;</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)

我的问题是如何删除这种不符合我们预期行为的默认自动对焦?

感谢您的阅读,请原谅拼写错误。

typescript ng-bootstrap ng-modal angular

5
推荐指数
3
解决办法
3049
查看次数

标签 统计

angular ×1

ng-bootstrap ×1

ng-modal ×1

typescript ×1