相关的<material-dropdown-select> [英] Dependent <material-dropdown-select>

查看:25
本文介绍了相关的<material-dropdown-select>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想链接多个,使用[(ngModel)] + (ngModelChange),使得他们依赖.(所以不能使用 *ngFor + .)

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> 依赖,这样当父"被更新时,第一个孩子"被更新/重置,并且然后当第一个孩子被选中时,第二个被重置/更新,依此类推.

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 不会更新...

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

这篇关于相关的&lt;material-dropdown-select&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆