-
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
Add 'otherwise' wrapper method to route-segment #44
base: master
Are you sure you want to change the base?
Conversation
Hm, wouldn't we probably want to assign |
Well, assigning to an URL instead of a segment name, enable use to declare otherwise before or after other when declarations, instead of only after, since we obviously want to fetch And assigning to a segment name seems not bring us any extra benefits. (Pls correct me if I was wrong.) (p.s. the param |
Hi @artch @tminglei I'm also interested in an otherwise/catch-all route into the package. $routeSegmentProvider
//normal route definitions
.when('/', 'home')
.when('/list/:category', 'list.category')
//the catch-all route
.else('/404', 'error') The potential here is to define a segment as per usual and use the above syntax to specify the $routeSegmentProvider.else = function(route, name) {
this.when(route, name);
$routeProvider.otherwise({redirectTo: route});
return this;
}; I'm happy to create a PR if you think this approach is valuable, otherwise it's a discussion point. @artch I guess it really depends on what you want to see, but I tend to agree with @tminglei's |
I got this error $routeSegmentProvider.when(...).when(...).otherwise is not a function where is the mistake? |
@sivascse there doesn't seem to be an $routeSegmentProvider.otherwise({
controller: 'notFound',
templateUrl: 'common/not-found.html'
}); |
I agree with @vdsabev. It would be great to display a template without having to redirect the user somewhere else, unless you decide to do so. |
What's the status here? +1 for @vdsabev's proposal! Redirecting is not a clean solution... |
This seems like a simple patch that would be very useful. Can we get this accepted? |
Hi @artch,
Your
angular-route-segment
not only added more features toangular-route
, but also made the usage more elegant and simple!This pull request is to add 'otherwise' wrapper method to
route-segment
.I know you want not to make unnecessary adjustment for
angular-route
. But this little change will make user codes more consistent, since you already adjusted the 'when' semantic.The
route-segment
'otherwise' can be used as below:Can you help review and give your suggestions?
Thanks for your awesome job! :D