Skip to content

Organize long list of routes #1262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
quanghoc opened this issue Aug 9, 2014 · 5 comments
Closed

Organize long list of routes #1262

quanghoc opened this issue Aug 9, 2014 · 5 comments

Comments

@quanghoc
Copy link

quanghoc commented Aug 9, 2014

I am using angular-ui-router https://github.com/angular-ui/ui-router for route management now. However, my $stateProvider is very long with 50 - 100 routes:

$stateProvider
    .state('state1', {
      url: "/state1",
      templateUrl: "partials/state1.html"
    })
    .state('state1.list', {
      url: "/list",
      templateUrl: "partials/state1.list.html",
      controller: function($scope) {
        $scope.items = ["A", "List", "Of", "Items"];
      }
    })
    .state('state2', {
      url: "/state2",
      templateUrl: "partials/state2.html"
    })
    .state('state2.list', {
      url: "/list",
        templateUrl: "partials/state2.list.html",
        controller: function($scope) {
          $scope.things = ["A", "Set", "Of", "Things"];
        }
      })
    })
    .state('add', {
      url: "/add",
      parent:"state2",
      templateUrl: "partials/add2.html"
    })
    .state('state3', {
      url: "/state2",
      templateUrl: "partials/state3.html"
    })
    .state('list', {
      url: "/list",
      parent:"state3",
      templateUrl: "partials/list3.html"
    })
.......

What is the best way to organize this? Is there a way to put everything in a nested JSON?

@ProLoser
Copy link
Member

My recommendation: https://github.com/ProLoser/angularjs-orm

Please close if you feel this suffice's

@quanghoc
Copy link
Author

I am not sure if this is the answer. Can you elaborate?

@ProLoser
Copy link
Member

Checkout the code organization. You will find that in this repo, I've distributed the states across multiple .config() calls, each one located in it's own respective module. The entire project (and related slides and talk) are about project structure which is essentially what you're asking.

If you're saying that you'd rather use some sort of JSON file though, you could create an iterator or lazy-load the routes.

@quanghoc
Copy link
Author

Oh I see your point. Basically split out into modules instead of a single big app.config

Let me test around some more

Close for now

@lucassus
Copy link

Here you could find my proposal #1051 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants