Angular 4 – Access to father element view is undefined with @ViewChild

Ask A Question

Login To post a question

I need to create a modal to manage errors. So I suppose that the best solution is to put this modal in my app.component so I can use a single modal in my project:

<my-dialog #MyErrorDialog>

now I need to open this modal in many components or services when an http code occurs but with the reference id:

@ViewChild('MyErrorDialog') MyErrorDialogReference:  MyDialog; 

MyErrorDialogReference in my child component/service is undefined because the modal is defined in the app component…

Anyone can help me? I can’t pass to all components my modal error reference with @Input/@Output 🙁

For more info please click here

Have a question or need a custom quote?