机会.model.ts:
const enum TipoSiNo {
SI, NO
}
export class Oportunidad {
constructor(
public resultadoValidacion?: TipoSiNo,
我需要使用枚举的可能值之一购买我的对象的值(value):
oportunidad-edit.component.ts:
添加:
const enum TipoSiNo {
SI, NO
}
this.oportunidad.resultadoValidacion === TipoSiNo.NO
给我以下错误
ERROR in [at-loader] ./src/main/webapp/app/entities/oportunidad/oportunidad-edit.component.ts:337:75
TS2365: Operator '===' cannot be applied to types 'TipoSiNo.NO' and 'TipoSiNo.NO'.
最佳答案
试试这个:
this.oportunidad.resultadoValidacion as TipoSiNo === TipoSiNo.NO as TipoSiNo
关于angular - 比较枚举 Angular 4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45210948/