英文:
Property 'DATCRE' does not exist
问题
export interface StandingResponse extends ApiResponse {
ORD_CLI: StandingOrderPortfolio[];
}
export interface StandingOrderPortfolio {
DEPO: number;
INTITULE1: string;
PHONE: string;
ORDDETAIL: {
DATCRE: string;
TITRE: {
ISIN: string;
}[];
}[];
}
{
"ORD_CLI": [
{
"DEPO": 123248626491,
"INTITULE1": "PORTEFEUILLE TB58",
"PHONE": "00",
"ORDDETAIL": [
{
"DATCRE": "2022-03-31",
"TITRE": {
"ISIN": "BE0947764743"
}
}
]
}
]
}
在HTML模板中,您可以添加DATECRE和ISIN如下:
<ng-container *ngFor="let standingOrders of standingResponse.ORD_CLI">
<tr *ngFor="let standingOrder of standingOrders.ORDDETAIL">
<td class="text-center">{{standingOrders.DEPO | accountDash}}</td>
<td>{{standingOrders.INTITULE1}}</td>
<td>{{standingOrders.PHONE}}</td>
<td>{{standingOrder.DATCRE}}</td>
<td>{{standingOrder.TITRE[0].ISIN}}</td>
</tr>
</ng-container>
感谢您的帮助。
英文:
I created an interface with multiple properties.
export interface StandingResponse extends ApiResponse {
ORD_CLI: StandingOrderPortfolio[];
}
export interface StandingOrderPortfolio {
DEPO: number;
INTITULE1: string;
PHONE: string;
ORDDETAIL: {
DATCRE: string;
TITRE: {
ISIN: string;
}[];
}[];
}
I copied the JSON below, is it correct please?
{
"ORD_CLI":[
{
"DEPO":123248626491,
"INTITULE1":"PORTEFEUILLE TB58",
"PHONE":"00",
"ORDDETAIL":[
{
"DATCRE":"2022-03-31",
"TITRE":{
"ISIN":"BE0947764743",
},
}
]
}
],
}
I display DEPO
, INTITULE1
, PHONE
without any problem. Now I would like to display DATCRE
and ISIN
.
In the HTML template, how can I add DATECRE and ISIN? I'm lost in the iterations?
<ng-container *ngFor="let standingOrders of standingResponse.ORD_CLI">
<tr *ngFor="let standingOrder of standingOrders.ORDDETAIL">
<td class="text-center">{{standingOrders.DEPO | accountDash}}</td>
<td>{{standingOrders.INTITULE1}}</td>
<td>{{standingOrders.PHONE}}</td>
</tr>
</ng-container>
Thank you for your help.
答案1
得分: 1
standingOrders.ORDDETAIL
是一个数组。您已经正确地使用 *ngFor
迭代了 standingOrders.ORDDETAIL
数组。
在 <tr>
元素内,您只需要使用 standingOrder.DATCRE
访问 DATECRE
。对于 ISIN
,您应该使用 standingOrder.TITRE.ISIN
访问。
您的HTML结构应该如下所示:
<ng-container *ngFor="let standingOrders of standingResponse.ORD_CLI">
<tr *ngFor="let standingOrder of standingOrders.ORDDETAIL">
...
<td>{{ standingOrder.DATCRE }}</td>
<td>{{ standingOrder.TITRE.ISIN }}</td>
</tr>
</ng-container>
英文:
standingOrders.ORDDETAIL
is an array. You are in the correct direction which you have done to iterate the standingOrders.ORDDETAIL
array with *ngFor
.
Within the <tr>
element, you just need to access DATECRE
with standingOrder.DATCRE
. For ISIN
, you should access with standingOrder.TITRE.ISIN
.
Your HTML structure should be looked as below:
<ng-container *ngFor="let standingOrders of standingResponse.ORD_CLI">
<tr *ngFor="let standingOrder of standingOrders.ORDDETAIL">
...
<td>{{ standingOrder.DATCRE }}</td>
<td>{{ standingOrder.TITRE.ISIN }}</td>
</tr>
</ng-container>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论