Skip to content
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

Complex route definition #95

Closed
stanleyxu2005 opened this issue Jul 5, 2015 · 1 comment
Closed

Complex route definition #95

stanleyxu2005 opened this issue Jul 5, 2015 · 1 comment

Comments

@stanleyxu2005
Copy link

I was searching for a better ngroute replacement these days. Although ui-router is more famous, but when I saw this one, I think this is the best choice! It took me only 5 minutes to solve all my problems. Awesome!

However the route definition looks a bit complex. Regarding the example at homepage:

$routeSegmentProvider.
    when('/section1',          's1').
    when('/section1/prefs',    's1.prefs').
    when('/section1/:id',      's1.itemInfo').
    when('/section1/:id/edit', 's1.itemInfo.edit').
    when('/section2',          's2').
    segment('s1', {
        templateUrl: 'templates/section1.html',
        controller: MainCtrl}).
    within().
        segment('home', {
            default: true,
            templateUrl: 'templates/section1/home.html'}).
        segment('itemInfo', {
            templateUrl: 'templates/section1/item.html',
            controller: Section1ItemCtrl,
            dependencies: ['id']}).
        within().
            segment('overview', {
                default: true
                templateUrl: 'templates/section1/item/overview.html'}).
            segment('edit', {
                 templateUrl: 'templates/section1/item/edit.html'}).
            up().
        segment('prefs', {
            templateUrl: 'templates/section1/prefs.html'}).
        up().
    segment('s2', {
        templateUrl: 'templates/section2.html',
        controller: MainCtrl});

I'd like to know, why we cannot put segment definition into when definition, which is more straightforward.

$routeSegmentProvider.
    when('/section1', 's1', {
       templateUrl: 'templates/section1.html',
       controller: MainCtrl}).
    when('/section1/:id', 's1.itemInfo', {
       templateUrl: 'templates/section1/item.html',
       controller: Section1ItemCtrl,
       dependencies: ['id']}).
    when('/section1/:id/edit', 's1.itemInfo.edit', {
       templateUrl: 'templates/section1/item/edit.html',
       dependencies: ['id']}).
    when('/section2', 's2', {
        templateUrl: 'templates/section2.html',
        controller: MainCtrl})
;

I'd like to know, if it can be improved in this way.

@stanleyxu2005
Copy link
Author

I started with angular-route-segment and now I've switched to ui-router, so I close this issue, as nobody responses.

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

1 participant