I have the following factory. I use it to store lists of tabs in various parts of my program.
myApp.factory('RootService', function($location) {
var tabList = [ ... ];
var loginTabList = [ ... ];
return {
setTabList: function(data) {
tabList = data;
},
getTabList: function(data) {
if ($location.path() !== '/login') { return tabList; }
else {
if (data === 0) { return loginTabList; }
else { return tabList; }
}
}
};
});
I wanted to move the initialization of these lists to my Java layer so that I can have them populate from an Oracle database. I have the back-end sorted out, but when I attempt to inject Restangular into the factory so that I can use it, the factory prevents AngularJS from functioning at all. With minor changes, I can get AngularJS to work again with one:
myApp.factory('RootService', function($location) { ... });
Or the other:
myApp.factory('RootService', ['Restangular', function(Restangular) { ... }]);
declarations but not both. Am I declaring the factory incorrectly? How can I use both Restangular and $location together?
myApp.factory('RootService', ['Restangular','$location', function(Restangular,$location) { ... }]);