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
MdDialog passing in data and or variables to modal #2552
Hi @crisbeto and @antonyRoberts ... I have been working through it and I notice that the way the example API shows how to do the diaglog there is a 2 component system. *** I don't like this methodology... The issue with that is accessing the class to fire the modal popup is probably the same class that has the data you need to access too... not to say there aren't ways to get around this but the point is still a concern. So what I did is pointed it to the same class.
This works per se but now I can't set the data.
For example...
title: string = 'book'; i
this is fine but what if I want to access data... i.e.
title: any = this.someFunction(dataPassedIn);
^^^^^ I can't do this. perhaps I am doing something wrong but any help would be appreciated.
Should I post this in the other issue forum? #2181
***Update... to the above concern I wish the modal pop would accomplish these things:
the dialog modal popup should be able to be called from any component including in and of itself.
(Component A calls component A and accesses data from Component A)
the dialog modal popup should be able to be called from another component while accessing data from a predeterminate component. (Component A calls component B and access Data from Component B)
the dialog modal popup should be able to be called from another component while accessing data from itself. (Component A calls component B and access Data from Component A)
the dialog modal popup should be able to be called from another component while accessing data from a predeterminate component and or itself. (Component A calls component B and access Data from Component A and or Component B)
export class ApiHelper {
selectedOption: any = this.openMessage();
messagetype: string;
name: string = 'paul';
constructor(
private http: Http,
public dialog: MdDialog,
//public dialogRef: MdDialogRef<DialogResultExampleDialog>
) { }
openDialog(errorMsg: string) {
let dialogRef = this.dialog.open(ApiHelper);
this.selectedOption = 'test here';
let blue = this.openMessage(errorMsg);
console.log('three he is ' + errorMsg + ' >>>> ' + blue);
console.error('this is errorMsg22222 = ' + errorMsg);
dialogRef.afterClosed().subscribe(result => {
this.messagetype = errorMsg;
this.selectedOption = blue;
});
}
openMessage(errorMsg: string) {
console.log('this is the open message9999 = ' + errorMsg)
this.selectedOption = errorMsg;
return this.selectedOption;
}
I would like for this >>>> selectedOption: any = this.openMessage(); to work but i get a typescript error that I am not matching in the function... i.e. errorMsg: string isn't being passed in...
Not sure where the openMessage comes from, but you're basically calling it in the constructor. In regards to getting a hold of the dialog instance, you can do that in the openDialog method with dialogRef.componentInstance.
Activity
antonyRoberts commentedon Jan 6, 2017
There is a pull request to make it easier
feat(dialog): add a config option for passing in data
In the mean time #1377 (comment)
crisbeto commentedon Jan 6, 2017
@antonyRoberts is right. I'll close this issue as a duplicate of #2181.
xtianus79 commentedon Jan 6, 2017
Hi @crisbeto and @antonyRoberts ... I have been working through it and I notice that the way the example API shows how to do the diaglog there is a 2 component system. *** I don't like this methodology... The issue with that is accessing the class to fire the modal popup is probably the same class that has the data you need to access too... not to say there aren't ways to get around this but the point is still a concern. So what I did is pointed it to the same class.
This works per se but now I can't set the data.
For example...
this is fine but what if I want to access data... i.e.
^^^^^ I can't do this. perhaps I am doing something wrong but any help would be appreciated.
Should I post this in the other issue forum? #2181
***Update... to the above concern I wish the modal pop would accomplish these things:
(Component A calls component A and accesses data from Component A)
crisbeto commentedon Jan 6, 2017
Not sure I get the issue @xtianus79. Can you post what your classes look like?
xtianus79 commentedon Jan 6, 2017
@crisbeto it is pretty straight forward...
}
}
I would like for this >>>> selectedOption: any = this.openMessage(); to work but i get a typescript error that I am not matching in the function... i.e. errorMsg: string isn't being passed in...
crisbeto commentedon Jan 6, 2017
Not sure where the
openMessagecomes from, but you're basically calling it in the constructor. In regards to getting a hold of the dialog instance, you can do that in theopenDialogmethod withdialogRef.componentInstance.xtianus79 commentedon Jan 6, 2017
@crisbeto you mean like dialogRef.ApiHelper ???
crisbeto commentedon Jan 6, 2017
No, literally
dialogRef.componentInstance.xtianus79 commentedon Jan 6, 2017
MMMMMMMMM.... @crisbeto You SIR... ARE THE MAN!!!! lol. ughhh understanding API's always helps!
I appreciate your help that did the trick...
I have to clean this up a lot but i will repost on plunkr to show what I did...
Again thanks!!
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.