-
Notifications
You must be signed in to change notification settings - Fork 100
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
Reversing Routes #34
Comments
Have you tried to define the routes in each module separately rather than in the initial config all together? Like this: angular.module('app.profile.main', ['route-segment', 'view-segment'])
.config(function($routeSegmentProvider) {
$routeSegmentProvider.when('/:user/', 'main.profile')
.within('main').segment('profile', {
templateUrl: '/views/partials/profile/index.html',
controller: 'profile:Main.IndexPage as IndexPage',
dependencies: ['user']
})
})
.controller('profile:Main.IndexPage', function() {
...
}) |
Yes, on the project I'm working on the various features are separated out into their own modules with their own route definitions. But I think I made this issue ticket in error. After creating this ticket, I returned to my code and looked at how I was defining the routes. Seems to work after I removed any dashes Resulting service seems to work nicely:
|
One of the things that always frustrated me about ngRoute was that I ended up hardcoding paths in my codebase. While this may be less typing initially, in the long run it leads to code that requires more work to maintain and integrate into other projects.
Coming from the Django world, where a Django project is made up of features modules, each describing their own url routes I became used to the concept of giving each route a shortname. Throughout my codebase (both project and the feature module) I would then build a url based on the short name and some parameters.
Fast forward to AngularJs, I created angular-named-routes. This works fine if you're only use ngRoutes, however I would like to utilise the nested view functionality of angular-route-segment.
Which leads me to my current situation: route-segment only exposes the first level of routes to ngRoute which means ngRoute has no idea what the path for a second level route might be.
I've created a gist with an attempt to illustrate the use case and some the start of a service that helps reverse a segment name into the full path:
https://gist.github.com/airtonix/9835196
The text was updated successfully, but these errors were encountered: