I have a component where i pass what i want to display inside a modal like this :
openConfirmModal() {
this.service.openmodal(
{
buttons: [ {name: 'Close'} ]
}
);
}
The modal service is like this :
openmodal(input: String) {
const dialogRef = this.dialog.open(popupComponent, {
data: new ModalConfirmData({
buttons: Object.values(data)[0]
})
});
}
Inside my popupComponent i have :
export class ModalPopupData {
actions: Array<Object>;
constructor(input?) {
if (input) {
this.buttons = input.buttons;
}
}
}
Now everything works fine with this, but what i want to do right now is to pass a function to my service in order for it to consume it. Something like this but i don't know how :
{
function: (modalComponent) => {
modalComponent.close();
}
}
asyncfrom the callback definition and handle the click event with:(click)="act.callback(this)".functionas acallback parameterwithout problem.