Hi David I wonder how to pass data to the Component Modal?
Right now I solved it using the ModalService with a property called "payload", and passed on the open() method. But I don't feel this is the right solution.
The modal would need to have the payload ready or do more things OnInit.
Maybe it's a good idea to have a look in the @angular/material code for the Dialog to see how things works there (by the way they use a Directive approach).
I am not absolutely sure but, you can maybe pass parameters using the componentRef.
// As in the blog post
this.componentRef = this.componentFactoryResolver
.resolveComponentFactory<T>(component)
.create(this.injector);
// Pass values. Something being an Input() of the component.
this.componentRef.instance.something = yourValue;
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi David I wonder how to pass data to the Component Modal?
Right now I solved it using the ModalService with a property called "payload", and passed on the open() method. But I don't feel this is the right solution.
The modal would need to have the payload ready or do more things OnInit.
Maybe it's a good idea to have a look in the @angular/material code for the Dialog to see how things works there (by the way they use a Directive approach).
Thank you, nice post 👍
Hi Julio,
I am not absolutely sure but, you can maybe pass parameters using the
componentRef
.