我正在使用 ngx-translate 做一個登錄表單,所有組件似乎都能正確翻譯。問題是提交按鈕不顯示其翻譯文本時。當它的硬編碼作業或當你點擊他時它也可以作業。任何人都知道這是一個錯誤還是我錯過了什么?
視頻:點我
HTML 代碼:
<form (ngSubmit)="login()" [formGroup]="credentials" class="center">
<ion-item fill="outline" style="margin-top: 16px;">
<ion-label position="floating">{{ "email" | translate }}</ion-label>
<ion-input formControlName="email"></ion-input>
</ion-item>
<ion-item fill="outline" style="margin-top: 16px;">
<ion-label position="floating">{{ "password" | translate }}</ion-label>
<ion-input formControlName="password"></ion-input>
</ion-item>
<ion-button type="submit" expand="block" style="margin-top: 16px; height: 55px;">{{
"signin" | translate }}</ion-button>
</form>
.ts 進口:
imports: [
CommonModule,
IonicModule,
RouterModule,
TranslateModule,
ReactiveFormsModule
]
uj5u.com熱心網友回復:
您必須使用構建器初始化表單組,例如:
constructor(private modalController: ModalController, private formBuilder: FormBuilder) { }
ngOnInit() {
this.credentials = this.formBuilder.group({
email: ['', [Validators.required, Validators.email]],
password: ['', [Validators.required, Validators.minLength(6)]]
})
}
如果您不這樣做,則控制臺中一定有一些錯誤,并且翻譯服務將無法按預期作業。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/450285.html
上一篇:Angular無法識別離子標簽
