我在 i18n 管理的 json 檔案中有一個這樣的物件。
"ST01P01": {
"warranties": {
"ij1ToIj5": "Indemnités journalières",
"overheadCosts": "Frais généraux",
"invalidity": "Frais généraux",
"death": "Décès",
"seriousIllnesses": "Maladies graves",
"educationAnnuity": "Rente éducation",
"jointAnnuity": "Rente conjoint",
"purchase": "purchase"
}
我嘗試在我的模板中像這樣迭代它但沒有成功......'鍵值管道無法識別。
<div *ngFor="let item of 'ST01P01.warranties' | translate | keyvalue">
{{item.key}}:{{item.value}}
</div>
謝謝你的幫助
uj5u.com熱心網友回復:
在 HTML 中這樣嘗試:
<div *ngFor="let item of testData.ST01P01.warranties | keyvalue">
Key: <b>{{item.key}}</b> and Value: <b>{{item.value}}</b>
</div>
和 TS 檔案:
testData = {
'ST01P01': {
"warranties": {
"ij1ToIj5": "Indemnités journalières",
"overheadCosts": "Frais généraux",
"invalidity": "Frais généraux",
"death": "Décès",
"seriousIllnesses": "Maladies graves",
"educationAnnuity": "Rente éducation",
"jointAnnuity": "Rente conjoint",
"purchase": "purchase"
}
}
};
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/535087.html
標籤:有角度的国际化
