@angular/material
offers a few items that can be displayed without including a selector in your HTML. For example, Snackbar can be shown by simply injecting an MdSnackBar
and then calling open
on it. You don't need to have anything like <md-snackbar></md-snackbar>
or <div mdSnackBar></div>
. When you call open, it is drawn at the top or bottom of your page regardless of where this was called from, and no selector element in the template is needed.
I'd like to create a component that works this way as well but I can't find a straightforward example of how to do this. I think likely I just don't know what this technique is called so I'm not sure what to search for.
All the examples I see of things opening dialogs or whatever require that you have the selector in the HTML, which I know how to do. Even PrimeNG's dialog requires that you include <p-confirmDialog></p-confirmDialog>
in your HTML to use it (from what I can tell).
How can I create a component that is shown dynamically with no selector in your template, such as the material snackbar?