【发布时间】:2018-08-30 06:34:49
【问题描述】:
我是 Angular 新手,目前无法让我的 JSON 信息协同工作。
我的服务中有临时 JSON 数据,它使用模型来定义 JSON 中的数据类型。我的目标是在我的数据的属性部分中有一个属性列表,以便在我的代码中我可以检查数组包含的属性。但是我不确定如何正确设置我的模型。
这是我的数据示例:
{
"Id": 4,
"Title": "Global Emerging Markets",
"Description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed sollicitudin ornare lectus, quis gravida tortor venenatis nec. ",
"IUrl": "www.google.com",
"FUrl": "www.google.com",
"OUrl": "www.google.com",
"WUrl": "www.google.com",
"MUrl": "www.google.com",
"Properties": ["institutional", "personal"],
},
这是我的模型(是的,我知道它可能非常错误):
export class Brands {
Id: number;
Title: string;
Description: string;
IUrl: string;
FUrl: string;
OUrl: string;
WUrl: string;
MUrl: string;
Properties: string;
}
目前我收到错误"Type 'string[]' is not assignable to type 'string'。
你知道我该如何更正我的代码吗?
【问题讨论】:
标签: arrays json string angular