-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ERROR Error: No provider for Token MdDialogData! #4086
Comments
Throwing an error, if no data is supplied, was intentional, but I can see how it could hinder re-usability. I'll add a default value for it. Until it gets in you can work around it by making the data optional (e.g. |
Adds a default value for the `MD_DIALOG_DATA` injection token, instead of throwing an error when it's not defined. Fixes angular#4086.
Small note for testing components which inject MAT_DIALOG_DATA:
You can add this to your TestBed configuration:
|
data which you are passing to dialog might be misssing |
Just for future reference. This worked for me when I faced the same issue today. Add
They will have a null value if the component is not used as a popup. If I omit the |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug, feature request, or proposal:
As of 2.0.0-beta.3, you need to inject the MD_DIALOG_DATA token in order to access the data property of the MdDialogConfig object. If you inject the MD_DIALOG_DATA token into a component that will be loaded into the dialog, and you do not pass data in, you will get
What is the expected behavior?
Do not throw an error and to return an empty object if none is passed in.
What is the current behavior?
What are the steps to reproduce?
Plunker
What is the use-case or motivation for changing an existing behavior?
Which versions of Angular, Material, OS, browsers are affected?
Angular Material 2.0.0-beta.3
Angular 4.00
Is there anything else we should know?
The text was updated successfully, but these errors were encountered: