Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Is there something like we know as .otherwise() in the new router? #110

Open
0x-r4bbit opened this issue Feb 18, 2015 · 13 comments
Open

Is there something like we know as .otherwise() in the new router? #110

0x-r4bbit opened this issue Feb 18, 2015 · 13 comments
Milestone

Comments

@0x-r4bbit
Copy link
Contributor

While it is pretty clear, how to force a redirect from one path to another path like this:

function AppController($router) {
  $router.config([
    {
      path: '/',
      redirectTo: '/welcome'
    },
    {
      path: '/welcome',
      component: 'welcome'
  ]);
}

I wonder if there's also a way to map any path, that doesn't match any specific configuration, to a defined component/path. So basically the equivalent of:

app.config(function ($routeProvider) {
  $routeProvider
    .when('/foo', {
      ...
    })
    .otherwise('/foo');
});

Is there something like this in the new router or at least planned?

@doukasd
Copy link

doukasd commented Oct 10, 2015

+1

3 similar comments
@soorajvnair
Copy link

+1

@lalmanzar
Copy link

+1

@johanleroch
Copy link

+1

@amritk
Copy link

amritk commented Jan 14, 2016

There is. Try

{
        path: '/**',
        component:' default'
}

@chainlist
Copy link

👍

If it's working, it would be nice to write about it in the documentation.
It's sad there is so many people looking for this feature for about 1 year now 👎

@amritk
Copy link

amritk commented Jan 14, 2016

There's documentation??

@chainlist
Copy link

You got a point there @amritk !
Well done sir!

@johanleroch
Copy link

It works, Thank you for your response @amritk !

@amritk
Copy link

amritk commented Jan 14, 2016

@chainlist @lejogacav you think you could help me out? How do you grab parameters?

{
        path: '/feed/:param',
        component:' default'
}

Now how would you grab :param in the controller? I don't think routeParams works with the component router.

@iksose
Copy link

iksose commented Jan 14, 2016

@amritk
Copy link

amritk commented Jan 14, 2016

@iksose Thanks. So you need a lifecycle hook to get the parameters?

@chainlist
Copy link

I guess @btford can close this issue now ! :)
Thanks @amritk for the answer!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

9 participants