Dependent

2019-08-21 12:34发布

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???

1条回答
迷人小祖宗
2楼-- · 2019-08-21 13:08

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…

查看更多
登录 后发表回答