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

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>
    ...
</my-dialog>

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 herehttps://stackoverflow.com/q/50842186

Have a question or need a custom quote?
info@smartinfocare.com