Topic: open modal with select material (diferent component)
hi, i try open a modal with select material option, but the select is in one component and modal is in another component, how i can open this modal. Or how i can open modal between components?
Regards
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Status
Open
Specification of the issue
- User: Pro
- Premium support: No
- Technology: MDB Angular
- MDB Version: -
- Device: -
- Browser: -
- OS: -
- Provided sample code: No
- Provided link: No
atineo@gmail.com pro commented 7 years ago
You can solve this by using an event emitter that you can fire when an option changes. I'm assuming your select option is a child component of the component that has the modals. For example in your child component with the select: @Output() onOptionChange: EventEmitter<string> = new EventEmitter(); changeOption() { this.onOptionChange.emit('a new value'); } on your parent component's html: <my-custom-component (onOptionChange)="showOptionModal($event)"></my-custom-component> on your parent component's typescript: showOptionModal($event) { // show some modal given your logic. } Hope it helps and is a bit clear.cliceduca pro commented 7 years ago
hi, thanks for help me, but the select is in the parent component, and modal is child, this solution dont work for me :(Damian Gemza staff commented 7 years ago
Dear cliceduca, Please try to add modal code to your app component and then create second component and paste there Material Select code. Then in your div with .modal-body class paste selector of second component. For me it works fine. Let me know how about you. Best Regards, Damianatineo@gmail.com pro commented 7 years ago
You can take a look at angular's ViewChild in order to get a reference of your child component from the parent. From there you can update the modal to open in your child component whenever your select option in the parent changes. Just one idea.