shmu80
1
I would like to get translate value in js, but failed.
Anybody able to advise how can I get ng2-translate value.
Below is my code
en.json
"title" : "Test Title",
app.js
this.translate.get(“title”).subscribe(this.translatedValue);
console.log("translates : " + this.translatedValue);
Console log
log translates : undefined
you can have a look to this post here
shmu80
3
I tried
console.log("translates : " + this.translate.get(‘title’).value);
and
console.log("translates : " + this.translate.instant(‘title’));
both also return me the same value “title”, but it should be “Test Title”
log translates : title
but if I put my code is after initiate translate service, the result is
log translates: undefined
I think you will need to show us a bit more code (init, import, etc)
which version are you using?
hi
can you solve the problem?
Yes. I solved.
Sample code:
this.translate.get(“title”).subscribe(res => {
console.log(“title:” + title);
});