Problem :
I have dynamic text that is coming from Json file. I am using translate.get() method like this:
this.translate.get('keyInJson').subscribe(res => {
this.valueFromJson = res;
/*
creating an object using above text
*/
});
As this is asynchronous I am not able to get the translated text when the page renders. I tried wrapping above method inside Observables , Promises but it's not able to get translated version of text during page load. I was able to get the translated text after trying different approaches but code became too complex and not reliable.
Expected/desired behavior Should load translated version of text
Reproduction of the problem Dynamically generate the text instead of hardcoding it on html and then try to render translated version.
Environment Angular2 , Typescript, Ionic 2
element in the middle of that statement. Please fix your code in your question. – cobolstinks Mar 24 '17 at 16:48