Dependent <material-dropdown-select>

Issue

I want to link multiple <material-dropdown-select>, using [(ngModel)] + (ngModelChange), making them dependent. (So not by using *ngFor + <material-select-item>.)

But I do not find how to make these <material-dropdown-select> dependent, such that when the “parent” is updated, the “first child” is updated/reset, and then when the first child is selected, the second is reset/updated, and so on.

I tried with querySelector() but obviously, this is not the good way.

Maybe with ViewChild/ViewChildren but the options list is not updated???

Solution

Well I finally get what I needed.

I used @ViewChild to target the element in the page.

But changing the options “was tricky”, as I had to first :

  • MaterialDropdownSelectComponent.options.dispose();

then

  • add the new list…

without the first step, the SelectionOptions<dynamic> is not updated…

Answered By – user8773215

Answer Checked By – Clifford M. (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *