2
I have the default site routes on a constant
:
app.constant('defaultRoutes', {
home: {
url: '/home',
templateUrl: 'templates/home.html',
controller: 'HomeController'
},
[...demais rotas....]
});
I’m calling this constant
in this provider
app.provider("routeConfig", function (defaultRoutes,$httpProvider) {
[... logica aqui...]
this.$get = defaultRoutes;
});
This provider
will be instantiated in the app.config()
app.config(function($stateProvider,$urlRouterProvider,routeConfigProvider) {
[...lógica para configurar as rotas...]
})
Until then it is working ok, but the doubt is: how could be made a way to give the option of who to use the class, overwrite the default values without changing the constant
?
I’ve tried to replace constant
for value
but this can only be used after initialization of app.config()
.
Actually this is not the case, I’m using
Angular-Ui-Router
to control routes, this explains my receiving app.config($stateProvider,$urlRouterProvider..
The point is, it’s working like this, but in a static way. I need to make it flexible so that thedefaultRoutes
may be overwritten– anisanwesley
But when you use app.Constant, you’re reporting a fixed variable or function or is immutable that is instantiated even before loading the methods. That way there’s no way to be flexible.
– andervoc
Just that the question: "What could I use to be flexible?"
– anisanwesley
Maybe the link can help you: http://odetocode.com/blogs/scott/archive/2013/06/decorating-angularjs-services.aspx
– andervoc