从属< material-dropdown-select> [英] Dependent <material-dropdown-select>
问题描述
我想使用[(ngModel)]
+ (ngModelChange)
链接多个<material-dropdown-select>
,使它们相互依赖. (因此,请勿使用*ngFor
+ <material-select-item>
.)
I want to link multiple <material-dropdown-select>
, using [(ngModel)]
+ (ngModelChange)
, making them dependent. (So not by using *ngFor
+ <material-select-item>
.)
但是我没有找到如何使这些<material-dropdown-select>
依赖的,因此,当父"被更新时,第一个孩子"被更新/重置,然后在选择第一个孩子时,第二个被重置/updated,依此类推.
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.
我尝试过querySelector()
,但是显然,这不是好方法.
I tried with querySelector()
but obviously, this is not the good way.
也许使用ViewChild
/ViewChildren
,但选项列表未更新?
Maybe with ViewChild
/ViewChildren
but the options list is not updated???
推荐答案
好吧,我终于得到了所需的东西.
Well I finally get what I needed.
我使用@ViewChild
定位页面中的元素.
I used @ViewChild
to target the element in the page.
但是更改选项很棘手",就像我必须首先要做的一样:
But changing the options "was tricky", as I had to first :
-
MaterialDropdownSelectComponent.options.dispose();
然后
- 添加新列表...
没有第一步,SelectionOptions<dynamic>
不会更新...
without the first step, the SelectionOptions<dynamic>
is not updated…
这篇关于从属< material-dropdown-select>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!