last day (15 days later) » 

11:29 AM
0
A: Close material dialog from shared service

Youssef TounoussiMaybe the DI by constructor of NotificationPopUpServiceService in each component is the solution, And inside your service : export class NotificationPopUpServiceService { constructor(public snackBar: MatSnackBar) {} config: MatSnackBarConfig = { duration: 3000, horizontalPosition: "right...

 
in NotificationPopUpServiceService, in constructor we need to set public dialogRef: MatDialogRef<COMPONENT_NAME> .How to define in your case constructor?
 
is your snackBar Material instance
 
I don't need to dismiss() snackBar, i need to close dialog
 
Are you looking for the component who invokes the success function ?
 
No, on success I only need to trigger this.dialogRef.close()
 
11:29 AM
I understand, so why not using an other function that has the close() function
hey
 
Hi, here is full case....image you are on user page
and you click on button +create new
you get modal with form field
now, I make one small service for show notifications on success or error etc
this notification service i call on every submit on any place in my app....
ok, now, go back to opened dialog... when I input all form data i click submit, and with action/reducer/effect i send data to backend...
in my effect i call my api link for sending data...
and now in effect if data successfully send i triger my service for showing success notification
Of course, on success i also need to close dialog box
Soo, best way for this is put also close function to notification.
But to close dialog, dialogRef need to know which dialog to close, I need to pass to them name of class (component)
and in constructor we dinamically need to change name of component public dialogRef: MatDialogRef<AssingTrialRoleComponent>
 

last day (15 days later) »