Join egghead, unlock knowledge.

Want more egghead? It's 45% off for a limited time only!

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock All Content for 45% Off

Already subscribed? Sign In

Save 45% for a limited time.

Get access to all courses and lessons on egghead today.

Autoplay

    Map a Second Angular Route to a Component

    John LindquistJohn Lindquist

    Mapping Angular routes to components is fairly straight-forward, but if you’re not going to lazy load in modules, then you’ll need to make sure to reference each Component you’re using in your main App Module.

    angularAngular
    2 - 4
    Code

    Code

    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    Transcript

    Transcript

    00:00 I'll create a second component in a folder called contacts. I'll say contacts.component.ts. This will just be a component with a template, this is a ContactsComponent. We'll export the class, ContactsComponent.

    00:17 Inside our app routes, just create another path. I'll duplicate this one. We'll say the path here is Contacts. When we hit Contacts, we want to load the ContactsComponent. We also need to declare in my AppModule the ContactsComponent.

    00:33 Now, I'm going to hit Save. I'll let this refresh and then I'll go to /contacts. Hit Enter. You see this is the ContactsComponent. If I go back to the route, you'll see that this is the HomeComponent.

    Discuss

    Discuss