简体   繁体   English

Angular 2:ng-select中的管道项目

[英]Angular 2: pipe items in ng-select

is there any way, how to pipe items in ng-select component? 有什么办法,如何在ng-select组件中传递项目?

Les say, I have list of items, having 2 types of values, "valueA" and "valueB": 莱斯说,我有项目列表,其中有两种类型的值:“ valueA”和“ valueB”:

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

Then I have switch: "Show Values A" / "Show Values B". 然后我切换:“显示值A” /“显示值B”。 Based of the value on the switch, in the dropdown I want see valuesA/valuesB. 基于开关上的值,在下拉列表中,我想查看valuesA / valuesB。

I am using ng-select from https://valor-software.com/ng2-select/ . 我正在使用https://valor-software.com/ng2-select/中的 ng-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. 我不认为我会在这里进行管道传输-我可能会使用* ngIf或有条件更新的单个后备字段来驱动下拉列表。

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

...

showA ? conditionalBackingData = valueAList : conditionalBackingData = valueBList;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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