The JavaScript object you return from your factory method is never updated with the new strings object. You need to retain a reference to it to be able to update the "public view":
service = {
Strings: strings,
GetStringResources: getStringResources
};
return service;
Then update your .then
callback to update both the private variable as well as the public service object:
.then(function(data) {
strings = service.strings = data;
deferred.resolve(data); // don't need to resolve this with the strings, but why not?
}, function error(){...});
However, since you no longer really have "private data" (only a private reference to the variable which is public), you don't really need to have the private strings variable at all:
io1App.factory('Resources', ['$rootScope', 'DataService', '$q',
function ($rootScope, DataService, $q) {
var urlBase = '/api/sfc/resource';
var service = {
// Need to pre-define 'ERROR_HEADER', since it is referenced in Index.html...before we have a chance to download it from the server.
Strings: { 'ERROR_HEADER': 'Error!' },
GetStringResources: function (locale) {
var url = urlBase + '/' + locale;
var deferred = $q.defer();
var promise = DataService.GetMethod(url);
// Note that DataService.GetMethod(...) is returning a $q promise
promise.then(function (data) {
service.strings = data;
deferred.resolve(data); // don't need to resolve this with the strings, but why not?
},
function (err) {
deferred.reject(err);
});
return deferred.promise;
};
return service;
}]);