Angular RESTAPI复杂响应的Typescript接口

Angular RESTAPI复杂响应的Typescript接口,angular,typescript,Angular,Typescript,我正在努力解决如何在typescript中处理来自VSTSAPI的响应 有没有办法处理这个接口 export interface Fields { 'System.AreaPath': any; 'System.TeamProject': string; 'System.IterationPath': string; 'System.WorkItemType': string; 'System.State': string; 'System.Reason': string; 'System.A

我正在努力解决如何在typescript中处理来自VSTSAPI的响应

有没有办法处理这个接口

export interface Fields {
'System.AreaPath': any;

'System.TeamProject': string;
'System.IterationPath': string;
'System.WorkItemType': string;
'System.State': string;
'System.Reason': string;
'System.AssignedTo': string;
'System.CreatedDate': Date;
'System.CreatedBy': string;
'System.ChangedDate': Date;
'System.ChangedBy': string;
'System.Title': string;
'Microsoft.VSTS.Feedback.ApplicationType': string;
'System.Description': string;
'System.History': string;
'Microsoft.VSTS.Feedback.ApplicationStartInformation': string;
'Microsoft.VSTS.Feedback.ApplicationLaunchInstructions': string;
}
在我的代码中,我尝试循环出字段(workItems==字段)



{{workitem.fields.System.AreaPath}
{{{workitem.fields['System.AreaPath']}}


工作?

{{workitem.fields['System.AreaPath']}}


有效吗?

首先,不能在对象上使用ngFor

其次,如果工作项是字段类型,则不需要任何循环来显示其属性之一。就像在JavaScript或TypeScript中一样,您只需要

workItems['System.AreaPath']

首先,不能在对象上使用ngFor

其次,如果工作项是字段类型,则不需要任何循环来显示其属性之一。就像在JavaScript或TypeScript中一样,您只需要

workItems['System.AreaPath']

感谢@elzoy和@JB Nizet,当接口上的属性“复杂”时,我需要['System.AreaPath']。我真的错过了typescript中的一些装饰程序,比如c#[JsonProperty]之类的。但这很有效

非常感谢-在你帮助我之前是不是浪费了几个小时


}多亏了@elzoy和@JB Nizet,当界面上的属性“复杂”时,我需要['System.AreaPath']。我真的错过了typescript中的一些装饰程序,比如c#[JsonProperty]之类的。但这很有效

非常感谢-在你帮助我之前是不是浪费了几个小时


}

item.fields['name.with.dots']item.fields['name.with.dots']您提到的ngFor部分是commented@Jota.Toledo不,不是。我引用:“workItems===Fields”[…]”您是对的,但仍然不清楚workItems是什么数据类型。我想op应该更新他的问题。您提到的ngFor部分是commented@Jota.Toledo不,不是。我引用:“workItems===字段”[…]”您是对的,但仍然不清楚workItems是什么数据类型。我想op应该更新他的问题。
      <tbody>
        <tr *ngFor="let workitem of workItems">

          <td>{{workitem.fields['System.AreaPath']}}</td>
        </tr>
      </tbody>


export interface Fields {

'System.AreaPath': string;

'System.TeamProject': string;
'System.IterationPath': string;
'System.WorkItemType': string;
'System.State': string;
'System.Reason': string;
'System.AssignedTo': string;
'System.CreatedDate': Date;
'System.CreatedBy': string;
'System.ChangedDate': Date;
'System.ChangedBy': string;
'System.Title': string;
'Microsoft.VSTS.Feedback.ApplicationType': string;
'System.Description': string;
'System.History': string;
'Microsoft.VSTS.Feedback.ApplicationStartInformation': string;
'Microsoft.VSTS.Feedback.ApplicationLaunchInstructions': string;
}

export interface WorkItemFullInformation {
id: number;
rev: number;
fields: Fields;
url: string;
export interface FetchWorkItemRootObject {
count: number;
value: WorkItemFullInformation[];