Dependent <material-dropdown-select>

北城以北 提交于 2019-12-25 04:16:32

问题


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:


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…



来源:https://stackoverflow.com/questions/52592943/dependent-material-dropdown-select

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!