0
我是TS和角4的新手。我需要能够显示角度材料2 MdSnackBar
内翻译CLOSE
字的用户。我明白,你可以从这样的代码中调用NGX-翻译翻译服务:ngx翻译与角材料2 MdSnackBar
this.translate.get('ERROR.CLOSE').subscribe((res: string) => {
console.log(res);
});
的事情是,我需要能够显示这个角度材料2元中调用MdSnackBar
。
我想是这样执行它:
this.snackBar.open(error, this.getCloseWord(), {
duration: 10000,
})
private getCloseWord() {
this.translate.get('ERROR.CLOSE').subscribe((res: string) => {
console.log(res);
});
}
但我不知道如何使getCloseWord()
方法返回一个正确的字串值,可观察到的。
谢谢!这就像一个魅力!如果我想同时翻译两个元素,该怎么办?如何调整请求以请求两个参数? –
我编辑了我的答案。希望这是你的问题。 –