I'm trying to make my router
, work a little differently. Today it looks like this, for example:
$routeProvider.
when('/cliente', {
templateUrl: '/cliente',
}).
when('/login', {
templateUrl: '/usuario/login',
}).
when('/home', {
templateUrl: '/home/home',
}).
when('/unauthentication', {
templateUrl: '/utils/unauthentication',
}).
otherwise({
redirectTo: '/home'
});
It is correct, but I would like a behavior that when passing this route, for example: #/cliente/data
, if it does not find it it only searches for #/cliente
, and then if it does not, it would go to otherwise
.
What I wanted was something like this, for example:
$routeProvider.
when('/cliente/get', {
templateUrl: '/cliente',
}).
// esses '...' não existe, só utilizei para representar qualquer coisa
when('/cliente/...', {
// aqui pegando tudo que iniciar com /cliente, menos /cliente/get que é uma rota especifica
templateUrl: '/cliente',
}).
otherwise({
redirectTo: '/home'
});
It would be a logic similar to the following:
Date the following route: #/foo/blah/blah2/foo2
;
#/foo/blah/blah2/foo2
; #/foo/blah/blah2
; #/foo/blah
; #/foo
; otherwise
; Questions
- Is there any way to set
$routeProvider
to this? - Or is there any extension of the default% of Angular.js that can use? And how would I use it to achieve this result?