如何使用 ngx-translate 将翻译后的数据设置为另一个组件的值
how to set the translated data as a value to another component using ngx-translate
我有两个组件:Appcomponent 和 LabelComponent
需要根据语言设置翻译值json 文件
label.component.html:
<ng-container *ngIf="!hideItem">
<label [ngClass]="class">
<ng-container *ngIf="hyperlink; else noLink">
<a [routerLink]="url">{{labelValue}}</a>
</ng-container>
<ng-template #noLink>
{{labelValue}}
</ng-template>
</label>
</ng-container>
app.component.html:
<div class="row ">
<div class="col-xl-2">
<a-label [labelValue]="'lbl_status' | translate"></a-label>
</div>
<div class="col-xl-4">
<a-drop-down [placeholder]="''" name="status" [dataReader]="'status'" [fieldLabel]="''"
[httpUrl]="'dropdown' | translate" [httpMethod]="'get'"
[displayField]="'value'" [valueField]="'code'" [width]="'150px'" [defaultValue]="'new'" >
</a-drop-down>
</div>
</div>
翻译后的值'lbl_status' |翻译显示在网页中,但未与 [labelValue] 绑定,因此我无法获取 label.componen.ts 中的值
@Input()labelValue : 字符串;
与'dropdown'的值相同 | translate 也没有设置为 [httpUrl]。我不知道这是不是延迟加载
在组件中包含 ngOnChanges(){} 方法并添加与 ngOnInit(){} 相同的行{}
我有两个组件:Appcomponent 和 LabelComponent 需要根据语言设置翻译值json 文件
label.component.html:
<ng-container *ngIf="!hideItem">
<label [ngClass]="class">
<ng-container *ngIf="hyperlink; else noLink">
<a [routerLink]="url">{{labelValue}}</a>
</ng-container>
<ng-template #noLink>
{{labelValue}}
</ng-template>
</label>
</ng-container>
app.component.html:
<div class="row ">
<div class="col-xl-2">
<a-label [labelValue]="'lbl_status' | translate"></a-label>
</div>
<div class="col-xl-4">
<a-drop-down [placeholder]="''" name="status" [dataReader]="'status'" [fieldLabel]="''"
[httpUrl]="'dropdown' | translate" [httpMethod]="'get'"
[displayField]="'value'" [valueField]="'code'" [width]="'150px'" [defaultValue]="'new'" >
</a-drop-down>
</div>
</div>
翻译后的值'lbl_status' |翻译显示在网页中,但未与 [labelValue] 绑定,因此我无法获取 label.componen.ts 中的值 @Input()labelValue : 字符串;
与'dropdown'的值相同 | translate 也没有设置为 [httpUrl]。我不知道这是不是延迟加载
在组件中包含 ngOnChanges(){} 方法并添加与 ngOnInit(){} 相同的行{}