I am currently working on developing a versatile Angular component that serves as a container for Material Angular dialogs. My aim is to be able to provide a child component or template to the container component and then utilize the MatDialog service to open it.
One approach I have taken is to build a DialogWrapperComponent which takes in a child component using @ContentChild. However, I have faced challenges when attempting to pass this child component to the MatDialog.open() method, resulting in unexpected behavior where the dialog does not open properly.
Here is an illustration of how my DialogWrapperComponent template looks like:
<!-- dialog-wrapper.component.html -->
<ng-container #templateRef>
<ng-content></ng-content>
</ng-container>
Furthermore, here is a simplified example showcasing how I am utilizing the DialogWrapperComponent in my parent component:
<!-- app.component.html -->
<app-dialog-wrapper>
<mat-dialog-content>
<!-- Content goes here -->
</mat-dialog-content>
</app-dialog-wrapper>
In my parent component, I am integrating the DialogWrapperComponent and attempting to pass the mat-dialog-content as the child component to be shown in the dialog popup. I am uncertain about what steps I may be missing or if there is a more effective method to achieve my objective of crafting a reusable Material Angular dialog wrapper component. Can anyone offer advice or propose a successful solution for creating such a component?