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()
方法返回一個正確的字串值,可觀察到的。
謝謝!這就像一個魅力!如果我想同時翻譯兩個元素,該怎麼辦?如何調整請求以請求兩個參數? –
我編輯了我的答案。希望這是你的問題。 –