[英]angular 2+ filtering 3 boolean values
id like to make a filter for this object id希望对此对象进行过滤
export interface Components {
verbal: boolean;
somatic: boolean;
material: boolean;
materialMaterial: string;
materialCost?: number;
}
id like to have 3 outputs true, false and any or null for example: verbal: true; id喜欢有3个输出true,false和any或null,例如:verbal:true; somatic: false;
躯体:假; material: null;
材质:null; will show all objects that have a verbal element do not have a somatic element and both material and not material elements.
将显示所有具有言语元素的物体均不具有躯体元素,并且既具有物质元素又非物质元素。 the only way I can think of doing this is to change the type.
我能想到的唯一方法是更改类型。 id like to know if this can be done without changing the type
id想知道是否可以在不更改类型的情况下完成此操作
These kind of case where enum
is useful. enum
很有用的这类情况。
You could create an enum
like 你可以创建一个
enum
enum ComponentValue{
Allow=1,
Ignore,
DontCare
}
And in your interface 并在您的界面中
export interface Components {
verbal: ComponentValue;
somatic: ComponentValue;
material: ComponentValue;
materialMaterial: string;
materialCost?: number;
} }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.