如何获取空对象打字稿的键

时间:2018-08-01 11:35:31

标签: javascript angular typescript

我如何使用打字稿获取角度上的空对象的键?

我的对象

export class ProdutoAgil{
    constructor() {}

    public IdEmpresa: number;
    public IdGrupo: number;
    public Nome: string;
    public Codigo: string;
    public ValorVenda: number;
    public Ncm: string;
    public IdImpostoIcms: number;
    public CustoMedio: number;
}

现在我需要捕获键,以便用它来做一个数组,像这样:

myArray: any[] = ['IdEmpresa','IdGrupo','Nome','Codigo','ValorVenda','Ncm','IdImpostoIcms','CustoMedio']

我尝试执行Object.keys(new ProdutoAgil()),但返回值为空

0 个答案:

没有答案