Property ‘DATCRE’ does not exist.

huangapple go评论62阅读模式
英文:

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?

{

   &quot;ORD_CLI&quot;:[
      {
         &quot;DEPO&quot;:123248626491,
         &quot;INTITULE1&quot;:&quot;PORTEFEUILLE TB58&quot;,
         &quot;PHONE&quot;:&quot;00&quot;,
         &quot;ORDDETAIL&quot;:[
            {
               &quot;DATCRE&quot;:&quot;2022-03-31&quot;,
               &quot;TITRE&quot;:{
                  &quot;ISIN&quot;:&quot;BE0947764743&quot;,
               },
            }
         ]
      }
   ],

}

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?

&lt;ng-container *ngFor=&quot;let standingOrders of standingResponse.ORD_CLI&quot;&gt;
   &lt;tr *ngFor=&quot;let standingOrder of standingOrders.ORDDETAIL&quot;&gt;
      &lt;td class=&quot;text-center&quot;&gt;{{standingOrders.DEPO | accountDash}}&lt;/td&gt;
      &lt;td&gt;{{standingOrders.INTITULE1}}&lt;/td&gt;
      &lt;td&gt;{{standingOrders.PHONE}}&lt;/td&gt;
   &lt;/tr&gt;
&lt;/ng-container&gt;

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 &lt;tr&gt; 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:

&lt;ng-container *ngFor=&quot;let standingOrders of standingResponse.ORD_CLI&quot;&gt;
  &lt;tr *ngFor=&quot;let standingOrder of standingOrders.ORDDETAIL&quot;&gt;
    ...

    &lt;td&gt;{{ standingOrder.DATCRE }}&lt;/td&gt;
    &lt;td&gt;{{ standingOrder.TITRE.ISIN }}&lt;/td&gt;
  &lt;/tr&gt;
&lt;/ng-container&gt;

huangapple
  • 本文由 发表于 2023年3月8日 19:31:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/75672463.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定