简体   繁体   中英

Angular 2: pipe items in ng-select

is there any way, how to pipe items in ng-select component?

Les say, I have list of items, having 2 types of values, "valueA" and "valueB":

export class Item {
   valueA: string;
   valueB: string;
}

Then I have switch: "Show Values A" / "Show Values B". Based of the value on the switch, in the dropdown I want see valuesA/valuesB.

I am using ng-select from https://valor-software.com/ng2-select/ .

Thanks for any suggestion.

I don't think I would pipe here -- I would probably use an *ngIf or a single backing field that conditionally updates to drive the dropdown.

<my-dropdown [data]="conditionalBackingData"></my-dropdown>

...

showA ? conditionalBackingData = valueAList : conditionalBackingData = valueBList;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM