I am trying to define a generic route which will handle most of request. 
Adding a route for each and every feature addition is what I feel not good 
and not maintainable.

So my target is to write a generic route and resolve the decencies 
dynamically, which include resolving all dependent controller & service 
files, resolving templateUrl and resolving controller name. *I can 
resolve/construct everything except controller name.* Please help me a way 
around

*My route with a custom resolver:*

 $routeProvider
 .when('/:module/:controller/:action?', routeResolver.resolve())


*Inside my custom resolver:*

function routeResolverProvider(){

this.$get= function(){
  return this;
}

this.resolve = function (options) {
 var route = {};

 route.templateUrl = function (params) {
     var path = String.format('/app/components/{0}/{1}.view.html', params.
module, params.controller);
     return path;
 };

 
//================================================================================
 route.controller='THIS IS WHAT I WANT TO CONSTRUCT FROM ROUTE as 
templateUrl'  
 
//================================================================================

 route.resolve = {
   loadDependencies: ['$q', '$rootScope', '$route', function ($q, $rootScope
, $route) {
      // MY RESOLVE LOGIC HERE
      // I construct dependent file path from route values
      // String.format('/app/components/{0}/{1}.controller.js', 
params.module, params.controller);
   }]
 };

 return route;
 }}

app.provider('routeResolver', routeResolverProvider)



Thanks,
Prem




-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to