When you are calling open() and just sending the string will not work. you should send Id instead.
You can follow this example and it will work perfectly fine.
Code.ts
import {NgbModal, ModalDismissReasons} from '@ng-bootstrap/ng-bootstrap';
constructor(private modalService: NgbModal){}
open(){
this.modalService.open(sayHello);
}
private getDismissReason(reason: any): string {
if (reason === ModalDismissReasons.ESC) {
return 'by pressing ESC';
} else if (reason === ModalDismissReasons.BACKDROP_CLICK) {
return 'by clicking on a backdrop';
} else {
return `with: ${reason}`;
}
}
Code.html
<ng-template ngbModalContainer></ng-template>
<ng-template #sayHello let-c="close" let-d="dismiss">
<div class="modal-header ">
<h6 class="modal-title text-uppercase ">Headding</h6>
<button type="button " class="close " aria-label="Close " (click)="d( 'Cross click') ">
<span aria-hidden="true ">×</span>
</button>
</div>
<div class="modal-header ">
HELLO :)
</div>
<div class="modal-footer">
<button class="btn " (click)="d( 'Cross click') ">Close</button>
</div>
</ng-template>
and don't forget to import
import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; in your app.module.ts
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
imports: [ NgbModule.forRoot(),
...
...
]
I think this should help.