I have component that has N amount of filters, and for each of those filters, there are M amount of values. I am trying to dynamically display both of these, but it doesn't seem to be working.
I was able to test the values and see if I was using the correct syntax to retrieve the data and the code is able to get the data from the objects. However, when using the dynamic filters, it looks like nothing is being ran past the dropdown <button>
tag.
You can look here at the StackBlitz project I made as a replica of my application.
I have printed the filters object to the console in the form it is returned when I call getFilters
from the HTML. As you can see, it is returning data, but none of the filterValues can be seen when the user clicks the dropdown.
I expect it to display each of the filterValues
, but instead nothing happens when I click the dropdown button. If I remove the dynamic features from it, I am able to see the values in the dropdown, but I would like for it to be dynamic. Any help would be greatly appreciated.
The relevant template code:
<div ngbDropdown class="d-inline-block" *ngFor="let filter of getFilters()">
<button class="btn btn-outline-primary" id="{{filter[0]-dropdown}}" ngbDropdownToggle>{{filter[1].displayName}}</button>
<div ngbDropdownMenu attr.aria-labelledby="{{filter[0]-dropdown}}">
<button ngbDropdownItem *ngFor="let val of filter[1].filterValues">{{val}}</button>
</div>
</div>
and the relevant TypeScript code:
getFilters() : [string, FilterItem][] {
...
return Array.from(this.filters.entries());
}