Add 'otherwise' wrapper method to route-segment#44
Add 'otherwise' wrapper method to route-segment#44tminglei wants to merge 2 commits intoartch:masterfrom tminglei:master
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-segmentnot 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