I want to load some configuration for each controller in the app.config section. Each controller needs a different, but not mutually exclusive, dataset to load. I can’t figure out how to achieve this.
.config(['$routeProvider', '$locationProvider',
function($routeProvider, $locationProvider){
$routeProvider
.when('/', {
templateUrl: "partials/pages/dashboard.html",
controller: "dashboard_controller",
resolve: { dash_config: 'SomeConfigD'},
})
.when('/a', {
templateUrl: "partials/pages/a.html",
controller: "a_controller",
resolve: { dash_config: 'SomeConfigA'},
})
}])
However, I do not want to write separate factories for someConfigAand someConfigD, since they share code. I want something like
app.factory('configFactory', function(...){
var factory = ;
function get1(){
}
function get2(){
}
function get3(){
}
factory.configA = function(){
};
factory.configD = function(){
};
})
How can i do this?
source
share