Hi Jamey,

Can you please tell me do you find any way to construct a dynamic route in 
config or any alternative way. I am also getting same issue and still not 
find a solution of that. 

Thanks 

On Wednesday, May 16, 2012 10:13:44 PM UTC+2, James Wright wrote:
>
> The DI for controllers seems pretty straight forward. What I am having 
> trouble with it how to do DI for config.
>
> I figured out how to load in some data for navigation in the module.run by 
> passing in the $http/$rootScope. I realize I could have made this a service 
> that i initialize etc, but I am trying to grok the DI.
>
> angular.module('styleguide', ['styleguide.service', 
> 'styleguide.directive', 'styleguide.filter']).
>     run(function ($rootScope, $http)
>     {
>         // Load in the navigation data
>         $http.get('js/data/topics.json').success(function (data)
>         {
>             $rootScope.topics = data;
>         });
>     }).
>
> Now how do I do the config????
>
> Default:
>     config(['$routeProvider', function ($routeProvider)
>     {
>
> Try 1 failed:
>     config(['$routeProvider', function ($routeProvider, $rootScope)
>     {
>
> Try 2 failed:
>     config(['$routeProvider', '$rootScope', function ($routeProvider)
>     {
>
> etc etc...
>
> basically it seems like module.config doesn't know anything about $http, 
> $rootScope etc...
>
> my end goal is to build my routes dynamically, so instead of this:
>
>         $routeProvider.
>         when('/overview', { template: 'partials/overview.html', 
> controller: 'DefaultCtrl' }).
>         when('/resources', { template: 'partials/resources.html', 
> controller: 'DefaultCtrl' }).
>
>
> I would do this:
>
>     angular.forEach($rootScope.topics, function (navitem)
>     {
>         //blah blah code here for routes
>     });
>
> So DI in controllers, I get. DI in the module.run, I get.
>
> Not so much in the module.config.
>
> Thanks,
>
> Jamey
>

-- 
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