Issue :
I am facing a challenge with fetching dynamic text from a JSON file and translating it using the translate.get() method in Angular2.
this.translate.get('keyInJson').subscribe(res => {
this.valueFromJson = res;
/*
creating an object using above text
*/
});
Since the translation process is asynchronous, I am unable to display the translated text on page load. I tried using Observables and Promises but couldn't achieve the desired outcome. While I did manage to get the translated text after trying different methods, the code became overly complex and unreliable.
Expected/desired behavior: The translated version of the text should be loaded successfully.
Steps to reproduce the issue: Generate the text dynamically instead of hardcoding it in HTML and attempt to render the translated version.
Environment: Angular2, Typescript, Ionic 2