Gary Gary - 11 months ago 135
Javascript Question

.otherwise or /** in the new Angular2 Router to route non-route through wild cards

How do i use wild cards to route when a non functional route is given in the new Router... like the ones .otherwise in 1.X router or /** in previous beta router ? Any example / plnkr code is highly appreciated

import { provideRouter, RouterConfig } from '@angular/router';

    const routes: RouterConfig = [
      { path: '**', component: PageNotFoundComponent }

    export const appRouterProviders = [

The ** denotes a wildcard path for our route. The router will match this route if the URL requested doesn't match any paths for routes defined in our configuration. This is useful for displaying a 404 page or redirecting to another route.

Take a look at the router docs