我想在TS中翻译吐司消息。
Angular ngx-translate usage in typescript 我指的是答案,
message: this.translate.instant('HOME.SCAN ENABLE')
AND
setTimeout(this.setStatus.bind(this), 5000, this.translate.instant('HOME.SCAN COMPLETED'))
翻译成功
但是
this.setStatus(this.translate.instant('HOME.SCAN MESSAGE'));
翻译失败 出现HOME.SCAN MESSAGE
这是我的家。
scan(){
this.setStatus(this.translate.instant('HOME.SCAN MESSAGE'));
this.devices = [];
this.ble.scan([Emm_SERVICE], 5).subscribe(
device => this.onDeviceDiscovered(device),
error => this.scanError(error)
);
setTimeout(this.setStatus.bind(this), 5000, this.translate.instant('HOME.SCAN COMPLETED'));
}
scanError(error) {
this.setStatus('Error ' + error);
let toast = this.toastCtrl.create({
message: this.translate.instant('HOME.SCAN ENABLE'),
position: 'middle',
duration: 5000
});
toast.present();
}
setStatus(message) {
console.log(message);
this.ngZone.run(() => {
this.statusMessage = message;
});
}