我有以下 JSON 对象:
Object { JP: "JAPAN", PAK: "PAKISTAN", IND: "INDIA", AUS: "AUSTRALIA" }
此 JSON 是从 get 返回的响应数据。call(HttpClient Angular)
所以现在,我需要将其填充到以下内容中以显示为下拉列表。
countryList: { countryCode: string; countryName :string }[];
我尝试执行以下操作:
for (const key in resData) {
if (resData.hasOwnProperty(key)) {
var obj ={
countryCode :key,
countryName : resData[key]
}
this.countryList.push(obj);
}
}
但是当我执行时,我得到这个错误
"_this.countryList.push is not a function"
我做错了什么?
Cats萌萌
芜湖不芜
白衣染霜花
相关分类