Wenn Sie @ng-bootstrap verwenden, verwenden Sie folgendes:
Komponente
import { Component, OnInit } from '@angular/core';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
@Component({
selector: 'example',
templateUrl: './example.component.html',
styleUrls: ['./example.component.scss'],
})
export class ExampleComponent implements OnInit {
constructor(
private ngbModal: NgbModal
) {}
ngOnInit(): void {
}
openModal(exampleModal: any, $event: any) {
this.ngbModal.open(exampleModal, {
size: 'lg', // set modal size
backdrop: 'static', // disable modal from closing on click outside
keyboard: false, // disable modal closing by keyboard esc
});
}
}
Vorlage
Test modal
Dieser Code wurde in Angular 9 getestet mit:
-
"@ng-bootstrap/ng-bootstrap": "^6.1.0",
-
"bootstrap": "^4.4.1",