Create advanced route in Angular.js

-1

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 ;

  • Would try the original route: #/foo/blah/blah2/foo2 ;
  • Would try the route: #/foo/blah/blah2 ;
  • Would try the route: #/foo/blah ;
  • Would try the route: #/foo ;
  • Yes it would go to 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?
    asked by anonymous 22.09.2014 / 18:15

    1 answer

    0

    Dude, I've answered two questions that can help you, follow the links:

    01.10.2014 / 23:14