英文:
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:"NEK01",
the variable is displayed in the template.
the column tariff 2 is the variable FRAIS_ETRANGERS
linked to CODE:"NEK03",
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
<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>
and the service
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
},
{
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:"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
},
{
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:"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
},
{
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:"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
},
{
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="svmInfo.PLN[0].CODE === 'NEK03'"
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 = "NEK01"
svmInfo.PLN[1].CODE = "NEK01"
svmInfo.PLN[2].CODE = "NEK03"
svmInfo.PLN[3].CODE = "NEK03"
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论