I have done a service that gets a json file from the server with the translated values of the labels of my webapp. Seems to work fine:
mobilityApp.service('serveiTraduccions', function($resource) {
this.getTranslation = function($scope) {
var languageFilePath = 'traduccions/traduccio_en.json';
$resource(languageFilePath).get(function (data) {
$scope.translation = data;
});
};
});
What I am trying to do is acces that "$scope.translation" from my controler, I tried all and nothing worked. The object is saved in my $scope as you can see:
how can I get the values of the "registroBtnRegistro", "registroErrorRegistro" etc ?
Thanks in advance !
I tried:
console.log($scope.translation);
-> undefinedconsole.log($scope['translation']);
-> undefinedconsole.log($scope.translation.registroBtnRegistro);
-> TypeError: Cannot read property 'registroBtnRegistro' of undefined console.log($scope.translation['registroBtnRegistro']); -> TypeError: Cannot read property 'registroBtnRegistro' of undefined