How to pass parameters by providers AngularJS?

2

I have the default site routes in constant :

app.constant('defaultRoutes', {
    home: {
        url: '/home',
        templateUrl: 'templates/home.html',
        controller: 'HomeController'
    },
   [...demais rotas....]
});

I am calling this constant in this provider

app.provider("routeConfig", function (defaultRoutes,$httpProvider) {
    [... logica aqui...]
    this.$get = defaultRoutes;
});

This provider will be instantiated in app.config()

app.config(function($stateProvider,$urlRouterProvider,routeConfigProvider) {
    [...lógica para configurar as rotas...]
})

Override the default values without changing the constant ?

p>

I've tried to replace constant with value but this can only be used after app.config() initialization.

    
asked by anonymous 16.04.2014 / 14:28

1 answer

0
app.config(['$routeProvider', '$logProvider', function ($routeProvider, $logProvider) {

// Configuração de rotas
$routeProvider
    .when('/page/:ID', {
        templateUrl: 'App/Views/page.html',
        controller: 'Controller'
    })
    .otherwise({
        redirectTo: '/'
    });

}]);

This is the way I use to pass ID as a parameter on my routes, using angular-route.js , which is called at module initialization:

var app = angular.module("app", ["ngRoute"]);
    
16.04.2014 / 15:18