首页 > 解决方案 > Angular i18n:将翻译字符串转发到自己的组件

问题描述

我有一个自己的组件,看起来像这样简化:

  <mat-form-field class="example-full-width">
    <mat-label>{{myLabel}}</mat-label>
    <input matInput placeholder="Ex. Pizza" value="Sushi">
  </mat-form-field>

ts代码中类似于

 @Input() myLabel:string;

当我现在想将它包含在我用于 HTML 部分的组件中时:

 <my-component [label]="'Favorite food'"></my-component>

我的问题:如何以label翻译的方式指定内容?它适用于i18n-label??? 或者我需要在组件中添加一些额外的东西吗?

标签: angularangular-i18n

解决方案


推荐阅读