AngularJS: Inject Restangular and use $location in factory -
i have following factory. use store lists of tabs in various parts of 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 move initialization of these lists java layer can have them populate oracle database. have back-end sorted out, when attempt inject restangular factory can use it, factory prevents angularjs functioning @ all. minor changes, can angularjs work again one:
myapp.factory('rootservice', function($location) { ... }); or other:
myapp.factory('rootservice', ['restangular', function(restangular) { ... }]); declarations not both. declaring factory incorrectly? how can use both restangular , $location together?
try using following:
myapp.factory('rootservice', ['restangular','$location', function(restangular, $location) { ... }]); it possible didnt use inline annotation both $location , restangular
more on here
Comments
Post a Comment