我无法显示一个变量。

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

I can't display a variable

问题

"the column tariff 1" 是与 CODE:"NEK01", 相关联的变量 FRAIS_ETRANGERS,该变量在模板中显示。

"the column tariff 2" 是与 CODE:"NEK03", 相关联的变量 FRAIS_ETRANGERS,我无法在模板中显示这个变量。

我不明白为什么无法显示 tariff 2?

以下是代码示例:

<ng-container *ngFor="let plnPlcInfo of tarificationTitre">
    <ng-container *ngFor="let svmInfo of plnPlcInfo.PLN_SVM">
        <tr class="text-center">
            <td>
                <ng-container *ngIf="svmInfo.PLN[0].CODE === 'NEK01'">
                    {{ svmInfo.PLN[0].PLAGE[0].FRAIS_ETRANGERS }} %
                </ng-container>
            </td>
            <td>
                <ng-container *ngIf="svmInfo.PLN[0].CODE === 'NEK03'">
                    {{ svmInfo.PLN[0].PLAGE[0].FRAIS_ETRANGERS }}
                </ng-container>
            </td>

            <td scope="col">{{ svmInfo.SVM }}</td>
        </tr>
    </ng-container>
</ng-container>

以及服务代码:

export class TodoService {
    
    PLN_PLC = [
        {
            PLACECODE: 26,
            PLACELABEL: "Fundsettle",
            PLN_SVM: [
                {
                    SVM: 16111801,
                    ISIN: "LU0100749679",
                    LABEL: "NEKR FD LIFESTYLE DYNAMICC",
                    PLN: [
                        {
                            CODE: "NEK01",
                            PLAN: 8,
                            CANAL: "*",
                            AV: "A",
                            LIB: "Fonds Amenkor 8",
                            DATEV_EFFECTIVE: "0001-01-01",
                            PLAGE: [
                                {
                                    BORNE: 9999999999999.99,
                                    FRAIS_BORDEREAU: 0.00,
                                    FRAIS_RETRAIT: 0.00,
                                    TYPE_COURTAGE: 1,
                                    COURTAGE: 0.00,
                                    MIN_COURTAGE: 0.00,
                                    TYPE_FRAIS_ETR: 1,
                                    FRAIS_ETRANGERS: 2.00,
                                    MIN_FRAIS_ETR: 0.00
                                },
                                // 其他数据...
                            ]
                        },
                        {
                            CODE: "NEK01",
                            PLAN: 8,
                            CANAL: "*",
                            AV: "V",
                            LIB: "Fonds Amenkor 8",
                            DATEV_EFFECTIVE: "0001-01-01",
                            PLAGE: [
                                {
                                    BORNE: 9999999999999.99,
                                    FRAIS_BORDEREAU: 0.00,
                                    FRAIS_RETRAIT: 0.00,
                                    TYPE_COURTAGE: 1,
                                    COURTAGE: 0.00,
                                    MIN_COURTAGE: 0.00,
                                    TYPE_FRAIS_ETR: 1,
                                    FRAIS_ETRANGERS: 0.00,
                                    MIN_FRAIS_ETR: 0.00
                                },
                                // 其他数据...
                            ]
                        },
                        {
                            CODE: "NEK03",
                            PLAN: 8,
                            CANAL: "*",
                            AV: "A",
                            LIB: "Fonds Amenkor 8 - Staff",
                            DATEV_EFFECTIVE: "0001-01-01",
                            PLAGE: [
                                {
                                    BORNE: 9999999999999.99,
                                    FRAIS_BORDEREAU: 0.00,
                                    FRAIS_RETRAIT: 0.00,
                                    TYPE_COURTAGE: 1,
                                    COURTAGE: 0.00,
                                    MIN_COURTAGE: 0.00,
                                    TYPE_FRAIS_ETR: 1,
                                    FRAIS_ETRANGERS: 1.00,
                                    MIN_FRAIS_ETR: 0.00
                                },
                                // 其他数据...
                            ]
                        },
                        {
                            CODE: "NEK03",
                            PLAN: 8,
                            CANAL: "*",
                            AV: "V",
                            LIB: "Fonds Amenkor 8 - Staff",
                            DATEV_EFFECTIVE: "0001-01-01",
                            PLAGE: [
                                {
                                    BORNE: 9999999999999.99,
                                    FRAIS_BORDEREAU: 0.00,
                                    FRAIS_RETRAIT: 0.00,
                                    TYPE_COURTAGE: 1,
                                    COURTAGE: 0.00,
                                    MIN_COURTAGE: 0.00,
                                    TYPE_FRAIS_ETR: 1,
                                    FRAIS_ETRANGERS: 0.00,
                                    MIN_FRAIS_ETR: 0.00
                                },
                                // 其他数据...
                            ]
                        }
                    ]
                }
            ]
        }
    ];

    constructor() {}
}

我通过 Stackblitz 创建了一个示例供您参考。感谢您的帮助。

英文:

the column tariff 1 is the variable FRAIS_ETRANGERS linked to CODE:&quot;NEK01&quot;, the variable is displayed in the template.

the column tariff 2 is the variable FRAIS_ETRANGERS linked to CODE:&quot;NEK03&quot;, I am unable to display this variable in the template.

我无法显示一个变量。

I don't understand why I can't display tariff 2?

Here is the code

&lt;ng-container *ngFor=&quot;let plnPlcInfo of tarificationTitre&quot;&gt;
&lt;ng-container *ngFor=&quot;let svmInfo of plnPlcInfo.PLN_SVM&quot;&gt;
&lt;tr class=&quot;text-center&quot;&gt;
&lt;td&gt;
&lt;ng-container *ngIf=&quot;svmInfo.PLN[0].CODE === &#39;NEK01&#39;&quot;&gt;
{{ svmInfo.PLN[0].PLAGE[0].FRAIS_ETRANGERS }} %
&lt;/ng-container&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;ng-container *ngIf=&quot;svmInfo.PLN[0].CODE === &#39;NEK03&#39;&quot;&gt;
{{ svmInfo.PLN[0].PLAGE[0].FRAIS_ETRANGERS }}
&lt;/ng-container&gt;
&lt;/td&gt;
&lt;td scope=&quot;col&quot;&gt;{{ svmInfo.SVM }}&lt;/td&gt;
&lt;/tr&gt;
&lt;/ng-container&gt;
&lt;/ng-container&gt;

and the service

export class TodoService {
PLN_PLC = [
{
PLACECODE: 26,
PLACELABEL: &quot;Fundsettle&quot;,
PLN_SVM: [
{
SVM: 16111801,
ISIN: &quot;LU0100749679&quot;,
LABEL: &quot;NEKR FD LIFESTYLE DYNAMICC&quot;,
PLN: [
{
CODE:&quot;NEK01&quot;,
PLAN:8,
CANAL:&quot;*&quot;,
AV:&quot;A&quot;,
LIB:&quot;Fonds Amenkor 8&quot;,
DATEV_EFFECTIVE:&quot;0001-01-01&quot;,
PLAGE:[
{
BORNE:9999999999999.99,
FRAIS_BORDEREAU:0.00,
FRAIS_RETRAIT:0.00,
TYPE_COURTAGE:1,
COURTAGE:0.00,
MIN_COURTAGE:0.00,
TYPE_FRAIS_ETR:1,
FRAIS_ETRANGERS:2.00,
MIN_FRAIS_ETR:0.00
},
{
BORNE:0.00,
FRAIS_BORDEREAU:0.00,
FRAIS_RETRAIT:0.00,
TYPE_COURTAGE:0,
COURTAGE:0.00,
MIN_COURTAGE:0.00,
TYPE_FRAIS_ETR:0,
FRAIS_ETRANGERS:0.00,
MIN_FRAIS_ETR:0.00
},
{
BORNE:0.00,
FRAIS_BORDEREAU:0.00,
FRAIS_RETRAIT:0.00,
TYPE_COURTAGE:0,
COURTAGE:0.00,
MIN_COURTAGE:0.00,
TYPE_FRAIS_ETR:0,
FRAIS_ETRANGERS:0.00,
MIN_FRAIS_ETR:0.00
},
{
BORNE:0.00,
FRAIS_BORDEREAU:0.00,
FRAIS_RETRAIT:0.00,
TYPE_COURTAGE:0,
COURTAGE:0.00,
MIN_COURTAGE:0.00,
TYPE_FRAIS_ETR:0,
FRAIS_ETRANGERS:0.00,
MIN_FRAIS_ETR:0.00
},
{
BORNE:0.00,
FRAIS_BORDEREAU:0.00,
FRAIS_RETRAIT:0.00,
TYPE_COURTAGE:0,
COURTAGE:0.00,
MIN_COURTAGE:0.00,
TYPE_FRAIS_ETR:0,
FRAIS_ETRANGERS:0.00,
MIN_FRAIS_ETR:0.00
}
]
},
{
CODE:&quot;NEK01&quot;,
PLAN:8,
CANAL:&quot;*&quot;,
AV:&quot;V&quot;,
LIB:&quot;Fonds Amenkor 8&quot;,
DATEV_EFFECTIVE:&quot;0001-01-01&quot;,
PLAGE:[
{
BORNE:9999999999999.99,
FRAIS_BORDEREAU:0.00,
FRAIS_RETRAIT:0.00,
TYPE_COURTAGE:1,
COURTAGE:0.00,
MIN_COURTAGE:0.00,
TYPE_FRAIS_ETR:1,
FRAIS_ETRANGERS:0.00,
MIN_FRAIS_ETR:0.00
},
{
BORNE:0.00,
FRAIS_BORDEREAU:0.00,
FRAIS_RETRAIT:0.00,
TYPE_COURTAGE:0,
COURTAGE:0.00,
MIN_COURTAGE:0.00,
TYPE_FRAIS_ETR:0,
FRAIS_ETRANGERS:0.00,
MIN_FRAIS_ETR:0.00
},
{
BORNE:0.00,
FRAIS_BORDEREAU:0.00,
FRAIS_RETRAIT:0.00,
TYPE_COURTAGE:0,
COURTAGE:0.00,
MIN_COURTAGE:0.00,
TYPE_FRAIS_ETR:0,
FRAIS_ETRANGERS:0.00,
MIN_FRAIS_ETR:0.00
},
{
BORNE:0.00,
FRAIS_BORDEREAU:0.00,
FRAIS_RETRAIT:0.00,
TYPE_COURTAGE:0,
COURTAGE:0.00,
MIN_COURTAGE:0.00,
TYPE_FRAIS_ETR:0,
FRAIS_ETRANGERS:0.00,
MIN_FRAIS_ETR:0.00
},
{
BORNE:0.00,
FRAIS_BORDEREAU:0.00,
FRAIS_RETRAIT:0.00,
TYPE_COURTAGE:0,
COURTAGE:0.00,
MIN_COURTAGE:0.00,
TYPE_FRAIS_ETR:0,
FRAIS_ETRANGERS:0.00,
MIN_FRAIS_ETR:0.00
}
]
},
{
CODE:&quot;NEK03&quot;,
PLAN:8,
CANAL:&quot;*&quot;,
AV:&quot;A&quot;,
LIB:&quot;Fonds Amenkor 8 - Staff&quot;,
DATEV_EFFECTIVE:&quot;0001-01-01&quot;,
PLAGE:[
{
BORNE:9999999999999.99,
FRAIS_BORDEREAU:0.00,
FRAIS_RETRAIT:0.00,
TYPE_COURTAGE:1,
COURTAGE:0.00,
MIN_COURTAGE:0.00,
TYPE_FRAIS_ETR:1,
FRAIS_ETRANGERS:1.00,
MIN_FRAIS_ETR:0.00
},
{
BORNE:0.00,
FRAIS_BORDEREAU:0.00,
FRAIS_RETRAIT:0.00,
TYPE_COURTAGE:0,
COURTAGE:0.00,
MIN_COURTAGE:0.00,
TYPE_FRAIS_ETR:0,
FRAIS_ETRANGERS:0.00,
MIN_FRAIS_ETR:0.00
},
{
BORNE:0.00,
FRAIS_BORDEREAU:0.00,
FRAIS_RETRAIT:0.00,
TYPE_COURTAGE:0,
COURTAGE:0.00,
MIN_COURTAGE:0.00,
TYPE_FRAIS_ETR:0,
FRAIS_ETRANGERS:0.00,
MIN_FRAIS_ETR:0.00
},
{
BORNE:0.00,
FRAIS_BORDEREAU:0.00,
FRAIS_RETRAIT:0.00,
TYPE_COURTAGE:0,
COURTAGE:0.00,
MIN_COURTAGE:0.00,
TYPE_FRAIS_ETR:0,
FRAIS_ETRANGERS:0.00,
MIN_FRAIS_ETR:0.00
},
{
BORNE:0.00,
FRAIS_BORDEREAU:0.00,
FRAIS_RETRAIT:0.00,
TYPE_COURTAGE:0,
COURTAGE:0.00,
MIN_COURTAGE:0.00,
TYPE_FRAIS_ETR:0,
FRAIS_ETRANGERS:0.00,
MIN_FRAIS_ETR:0.00
}
]
},
{
CODE:&quot;NEK03&quot;,
PLAN:8,
CANAL:&quot;*&quot;,
AV:&quot;V&quot;,
LIB:&quot;Fonds Amenkor 8 - Staff&quot;,
DATEV_EFFECTIVE:&quot;0001-01-01&quot;,
PLAGE:[
{
BORNE:9999999999999.99,
FRAIS_BORDEREAU:0.00,
FRAIS_RETRAIT:0.00,
TYPE_COURTAGE:1,
COURTAGE:0.00,
MIN_COURTAGE:0.00,
TYPE_FRAIS_ETR:1,
FRAIS_ETRANGERS:0.00,
MIN_FRAIS_ETR:0.00
},
{
BORNE:0.00,
FRAIS_BORDEREAU:0.00,
FRAIS_RETRAIT:0.00,
TYPE_COURTAGE:0,
COURTAGE:0.00,
MIN_COURTAGE:0.00,
TYPE_FRAIS_ETR:0,
FRAIS_ETRANGERS:0.00,
MIN_FRAIS_ETR:0.00
},
{
BORNE:0.00,
FRAIS_BORDEREAU:0.00,
FRAIS_RETRAIT:0.00,
TYPE_COURTAGE:0,
COURTAGE:0.00,
MIN_COURTAGE:0.00,
TYPE_FRAIS_ETR:0,
FRAIS_ETRANGERS:0.00,
MIN_FRAIS_ETR:0.00
},
{
BORNE:0.00,
FRAIS_BORDEREAU:0.00,
FRAIS_RETRAIT:0.00,
TYPE_COURTAGE:0,
COURTAGE:0.00,
MIN_COURTAGE:0.00,
TYPE_FRAIS_ETR:0,
FRAIS_ETRANGERS:0.00,
MIN_FRAIS_ETR:0.00
},
{
BORNE:0.00,
FRAIS_BORDEREAU:0.00,
FRAIS_RETRAIT:0.00,
TYPE_COURTAGE:0,
COURTAGE:0.00,
MIN_COURTAGE:0.00,
TYPE_FRAIS_ETR:0,
FRAIS_ETRANGERS:0.00,
MIN_FRAIS_ETR:0.00
}
]
}
]
}
]
}
];
constructor() {}
}

I created an illustration via Stackblitz.

Thank you for your help

答案1

得分: 1

如果您查看您的数据结构,您会发现 svmInfo.PLN[0].CODE 总是等于 NEK01,所以 *ngIf="svmInfo.PLN[0].CODE === 'NEK03'" 永远不会评估为真。

您可能还需要循环遍历您的 PLN 索引,因为以下值已设置:

svmInfo.PLN[0].CODE = "NEK01"
svmInfo.PLN[1].CODE = "NEK01"
svmInfo.PLN[2].CODE = "NEK03"
svmInfo.PLN[3].CODE = "NEK03"
英文:

If you take a look at your data structure, you will see that svmInfo.PLN[0].CODE is always equal to NEK01 so *ngIf=&quot;svmInfo.PLN[0].CODE === &#39;NEK03&#39;&quot; will never evaluate to true.

You may need to loop through your index for PLN as well since the following values are set:

svmInfo.PLN[0].CODE = &quot;NEK01&quot;
svmInfo.PLN[1].CODE = &quot;NEK01&quot;
svmInfo.PLN[2].CODE = &quot;NEK03&quot;
svmInfo.PLN[3].CODE = &quot;NEK03&quot;

huangapple
  • 本文由 发表于 2023年6月8日 05:12:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/76427142.html
匿名

发表评论

匿名网友

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

确定