Description
Bug, feature request, or proposal: Proposal
What is the expected behavior?
Pass data to a component opened by the dialog service without depending on the dialog instance.
What is the current behavior?
You can pass data to a component by accessing it's instance and setting a predefined property.
What is the use-case or motivation for changing an existing behavior?
There are several ways to communicate with a dialog component:
- Custom Dependency injection - Set Providers as part of the options
- Fixed Dependency injection - Set a single data item as part of the options, injected via a token.
MdDialogRef
as a carrier - Set a single data item as part of the options, component consumed via MdDialogRef.data.- Direct assignment - Current behavior
The current behavior allow (4) and a limited (1)
(1) Only predefined providers.
It does not fit the angular pattern.
Angular uses DI a lot, this is part of the flow.
- Automatic errors if DI mismatch
- Allows proper use of hooks
- Less dependant
Since the dialog service abstract the component instantiation there is no control over the providers.
However, this process does allow changing providers by supplying an injector...
So all in all I think it should be possible to get some sort of control over the DI.
Workaround:
My current workaround is to create a service wrapping MdDialog.
This services uses a wrapper component as the Component to create.
The wrapper component then create the original component inside it with the supplied providers.