I have a modal wrapped in ng-template,
<ng-template #template>
<div class="modal-header">
<h4 class="modal-title pull-left">Modal for user id : {{ modalService.config.initialState.id }}</h4>
<button type="button" class="close pull-right" aria-label="Close" (click)="modalRef.hide()">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
This is a modal.
</div>
</ng-template>
i have a button to open this modal like
<button type="button" class="btn btn-primary" (click)="openModal(template)">Create template modal</button>
openModal(template: TemplateRef<any>) {
const user = {
id: 10
};
this.modalRef = this.modalService.show(template, {
initialState : user
});
}
this will work as i am passing template as a parameter.
How can i open this modal without passing the parameter? let it be i dont have a button, i want to open the modal on ngOninit. How it is possible?