Angular如何插入一个接口的数据

问题描述 投票:-1回答:1
export interface _ProjectBudgetHistories {
  createdBy?: string ;
  id?: number;
  budgetYear? : number ;
  logicalFrameworkId? : number  ;
  projectId?: number ;
  amount?: number ;
  mooe?: number ;
  co?: number;
}

pbHistories : _ProjectBudgetHistories;
let co =500;
let mooe =1000;

this.pbHistories.co = co;
this.pbHistories.mooe = mooe;

console.log(this.pbHistories);

这是错误TypeError:无法设置未定义的属性'co'TypeError:无法设置undefined属性'mooe'

=== >>如何更新mooe和co只有???

angular typescript interface
1个回答
0
投票

初始化您的财产

pbHistories : _ProjectBudgetHistories = {};
© www.soinside.com 2019 - 2024. All rights reserved.