我正在尝试使用json文件在我的应用程序中实现i18n,以进行语言转换。我能够成功地翻译为静态文本。但我无法转换为动态文本和使用*ngFor循环显示在数组中的文本。例如:我通过*ngFor使用数组在仪表板中显示了一组列表
let tempIcons = [{
id: 1,
name: test,
iconName: resultset,
iconDesc: usesd in home page
},
{
id: 2,
name: test12,
iconName: resultset23,
iconDesc: usesd in contact page
},
{
id: 3,
name: test23,
iconName: resultset23,
iconDesc: usesd in about us page
}]此外,我想改变语言的动态文本,我从api服务从后端获得。有人能给我这些场景的例子吗?
我正在使用带有i18n的Angular 8。
提前感谢
发布于 2021-04-10 19:52:06
像这样使用它:
<div *ngFor="let item of tempIcons">
{{'TRANSLATEPATH.' + item.name.toUpperCase() | translate}}
</div>https://stackoverflow.com/questions/67032236
复制相似问题