Reputation: 38
I'm using @angular/router @ version 2.0.0-rc.1
I can't seem to get wildcard parameters working, and from reading the code it seems there is no support.
Upvotes: 1
Views: 3134
Reputation: 290
With the Angular 2.0.0 (final release) and the new router you can normally use wildcards, now paths are being used without slash.
NOTE:
the order of the routes matters: it should go from the most specific to the least specific. So as for the simple example below, the route '**' (matches anything) should be put at the end, so all the other possible routes would be covered by the previous ones.
const routes: Routes = [
{
{ path: 'login', component: LoginComponent },
{ path: 'register', component: RegisterComponent },
{ path: '**', component: LoginComponent },
];
Upvotes: 3
Reputation: 616
You can do like this in app.ts
import {Home} from './Home';
...
@RouteConfig([
{ path: '/home', component: Home, name: 'Home' },
{ path: '/**', redirectTo: ['Home'] }
])
In this example,we only have one real route set up, and that is the /home route. We are also instructing the app to redirect any request to unrecognized routes to the Home component. Each RouteDefinition requires a path, a name, and either a component, loader, or redirectTo.
Upvotes: 1