-
-
Notifications
You must be signed in to change notification settings - Fork 592
Description
I'm submitting a ... (check one with "x")
[X] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request
Current behavior
using the translateservice.get()
method inside a constructor of a provider/service in ionic 3 does return the translation Keys instead of their values in the subscription.
Expected/desired behavior
I would expect the translateserice.get()
method to work in a service (@Injectable) constructor so that I can store the values retrieved in a plain javascript array to use them in my service's methods.
Reproduction of the problem
@Injectable()
export class UserService {
constructor(private translateService : TranslateService){
private translations : [string];
this.translateService.get(['SIGNUP_SUCCESS','DOES_NOTEXIST'])
.subscribe(values=> {
this.translations = values; //resolves to {DOES_NOTEXIST : "DOES_NOTEXIST", SIGNUP_SUCCESS:"SIGNUP_SUCCESS"}
})
}
}
In a @page or outside of the constructor (inside a method of the UserService) it will work. My providers are added to the app.module.ts file. There the UserService provider is added to the providers Array. And there also is the following :
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: (createTranslateLoader),
deps: [HttpClient]
}
}),
Please tell us about your environment:
-
ngx-translate version: 8.0.0
-
Angular version: 5.0.0
-
Browser: [Chrome 63]