Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Routes #7

Merged
merged 8 commits into from
Nov 19, 2017
Merged

Routes #7

merged 8 commits into from
Nov 19, 2017

Conversation

brunolm
Copy link
Owner

@brunolm brunolm commented Nov 18, 2017

Adding routes a43ba58

You have to create an object of type Routes from from '@angular/router and add RouterModule.forRoot(routes); to the imports of your module.

The root component and every component that has child routes need to have the router-outlet in the markup (50b393f):

<router-outlet></router-outlet>

To make a route for / and redirect to a submodule you can do:

{ path: '', redirectTo: 'tutorials', pathMatch: 'full' },

You can have nested "templates" by adding a component to a route and adding children to it

  {
    path: '',
    component: LayoutComponent,
    children: ...

You can add lazy loading components with loadChildren

loadChildren: 'app/tutorials/tutorials.module#TutorialsModule'

To enable tracing (debug purposes) pass an option to root route config

export const AppRoutingModule = RouterModule.forRoot(routes, {
  enableTracing: true
});

Unit Tests fb8b778

Tests must include RouterTestingModule in the TestBed imports:

import { RouterTestingModule } from '@angular/router/testing';
...
imports: [RouterTestingModule],

routes

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling fb8b778 on routes into 8a8dede on master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling ad9a6b4 on routes into 8a8dede on master.

@brunolm brunolm merged commit f72ef9b into master Nov 19, 2017
@brunolm brunolm deleted the routes branch November 20, 2017 00:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants