You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Documentation is unclear about how to get data into a Dialog. #1947
When I use the MdDialog service to open a dialog with some component, I'd love to be able to pass some configuration into that component.
What is the current behavior?
The dialogRef exposes componentInstance, which allows me to set properties / call functions on the component after construction, however I'm unsure if this is the recommended approach since it is not mentioned in the docs.
What is the use-case or motivation for changing an existing behavior?
It would improve the documentation and reduce the number of future issues.
Which versions of Angular, Material, OS, browsers are affected?
Latest /all
Is there anything else we should know?
I can submit a PR for improved documentation of an answer from this threads provides sufficient information!
Reacted by Abbas Monfared, tom-startsat60, Zhongyue Huang, Mario Kunz, eagle-dan1349, David Reher, Jason Yeomans, alexander taylor, Mehdi Saeedifar and Mac
The dialogRef exposes componentInstance, which allows me to set properties / call functions on the component after construction, however I'm unsure if this is the recommended approach since it is not mentioned in the docs.
Activity
DzmitryShylovich commentedon Nov 23, 2016
#1377 (comment)
eagle-dan1349 commentedon Nov 30, 2016
@SamMousa, as I see it's actually the only way to do it directly. You can use an injected service for that, but, IMHO, it would be an overkill.
SamMousa commentedon Dec 8, 2016
I've added this to my todo list.
tmburnell commentedon Feb 13, 2017
Is there any timeframe of when this will be added? if not could a code snippet be created here to show how to do it?
SamMousa commentedon Feb 13, 2017
@tmburnell I'm currently no longer working on an angular related project so it's low on the list.
tmburnell commentedon Feb 14, 2017
I figured it out from another post:
use this when opening
use this in the modal
M-a-c commentedon Apr 4, 2017
@SamMousa
I know in general components should share data (typically modeled data) with a service. (depending on what you're doing) But Yeah the docs dont really show how to pass data in, I'm getting a pr in for that.
https://angular.io/docs/ts/latest/cookbook/component-communication.html#!#bidirectional-service
@tmburnell this is the way I found it used in the source.
https://plnkr.co/edit/vpTaIAdIJnjd7ngFG2Ea?p=preview
SamMousa commentedon Apr 5, 2017
I'm gonna close this since I no longer expect I'll be working on it in the foreseeable future.
M-a-c commentedon Apr 5, 2017
@SamMousa I have a PR out for this, you were right about it being confusing. I'm trying to fix that in the docs.
angular-automatic-lock-bot commentedon Sep 5, 2019
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.