Skip to content

Instantly share code, notes, and snippets.

@brandonroberts
Last active June 22, 2016 13:00
Show Gist options
  • Save brandonroberts/f930c58e546ea7239b96cb6ca8ea5f84 to your computer and use it in GitHub Desktop.
Save brandonroberts/f930c58e546ea7239b96cb6ca8ea5f84 to your computer and use it in GitHub Desktop.
Angular 2 Route Map
const ROUTES = [
  {
    path: '',
    component: HomeComponent
  },
  ...PARENT_ROUTES
]

const PARENT_ROUTES = [
  {
    path: '/parent',
    component: ParentComponent,
    children: [
      {
        path: '/child',
        component: ChildComponent,
        children: [
          {
            path: '/grandchild',
            component: GrandChildComponent
          }
        ]        
      }
    ]
  }
]
const ROUTES = [
  {
    path: '',
    component: HomeComponent
  },
  ...PARENT_ROUTES
]

const PARENT_ROUTES = [
  {
    path: '/parent',
    component: ParentComponent,
    children: [
      ...CHILD_ROUTES
    ]
  }
]

const CHILD_ROUTES = [
  {
    path: '/child',
    component: ChildComponent,
    children: [
      {
        path: '/grandchild',
        component: GrandChildComponent
      }
    ]        
  }
]
const ROUTES = [
  {
    path: '',
    component: HomeComponent
  },
  {
    path: '/parent',
    component: ParentComponent,
    children: [
      {
        path: '/child',
        component: ChildComponent,
        children: [
          {
            path: '/grandchild',
            component: GrandChildComponent
          }
        ]        
      }
    ]
  }
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment