#how to get the options property from listbox in angular material?

7 messages · Page 1 of 1 (latest)

winged helm
unborn ginkgo
#

your stackblitz link doesn't work 😉

winged helm
unborn ginkgo
#

you can do (this.listbox as any).options but it's a bit hacky.
options is not officially exposed, so in future updates they could change it and brake your code

#

can I may ask why you want access to options ?

#

maybe somethink in this direction would also solve your problem:

  @ViewChildren("li") options: QueryList<ElementRef>;
winged helm
#

well, I also think (this.listbox as any).options is bit hacky.
but in my real app I have only the listbox instance.

  this.cdkListbox.valueChange
      .subscribe((value: ListboxValueChangeEvent<any>) => {
         val.listbox
       });

And I need access to the options inside that function. i do not have ViewChild.

So is it possible to get the options (cdkoption) in another way?