2016-07-27 26 views
2

我使用translate.instant,使一個字符串連接像

var variable = this.$translate.instant('project.discount') + " % " + this.$translate.instant('project.applied_to') + " " +this.office; 

我怎樣才能做到這裏面一個$ translate.instant作爲串插,而不是級聯

感謝,

+0

串聯工作正常,並沒有問題,但想與插值只是爲了使它更優雅,這是所有 –

回答

3

我想你想要的是

var variable = $translate.instant('project.discountAndAppliedTo', {office: this.office}); 

假設

{ 
    "project.discountAndAppliedTo": "discount % applied to {{office}}" 
} 

或者類似的東西,關鍵點是在{{}}在翻譯價值的插值變量名。

相關問題