I have an Angular service that handles translation through a call to my Web API backend, like so:
self.Translate = function (languageCode, keyword) {
var defer = $q.defer();
var uri = "api/translation/translate/" + languageCode + "/" + keyword;
apiService.Get(uri).then(function (translation) {
defer.resolve(translation.Text);
}, function (error) {
var msg = "Unable to translate keyword '" + keyword + "' for language code '" + languageCode + "'. Make sure that you can connect to the Web API and that the requested translation exists.";
loggerService.Error(self.Name, msg);
defer.reject(msg);
});
return defer.promise;
}
It is called like so:
var text = translationService.Translate("FR", "dateOfBirth");
Which would return:
date de naissance
However, on the receiving end I get this (in console.log):
d {$$state: Object}
$$state: Object
status: 1
value: "date de naissance"
__proto__: Object
__proto__: d
Which results to [object Object]
being shown, not the translated text.
Based on the above you would think that the following would work:
var text = translationService.Translate("FR", dateOfBirth).value;
But it doesn't, it returns undefined
.
Any idea what's going on and how I can fix this? Thanks!
PS: You can find the full service code here (script only), to be complete.