Topic: open modal with select material (diferent component)

cliceduca pro asked 6 years ago


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

Alejandro pro commented 6 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 6 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 6 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, Damian

Alejandro pro commented 6 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.


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Opened

Specification of the issue

  • ForumUser: Pro
  • Premium support: No
  • Technology: MDB Angular
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: No
Tags