Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Angular Router

You're reading from   Angular Router From Angular core team member and creator of the router

Arrow left icon
Product type Paperback
Published in Mar 2017
Publisher Packt
ISBN-13 9781787288904
Length 118 pages
Edition 1st Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
Victor Savkin Victor Savkin
Author Profile Icon Victor Savkin
Victor Savkin
Arrow right icon
View More author details
Toc

One redirect at a time


You can set up redirects at different levels of your router configuration. Let's modify the preceding example to illustrate this:

[
  {
    path: 'legacy/:folder/:id',
    redirectTo: ':folder/:id'
  },
  {
    path: ':folder/:id',
    component: ConversationCmp,
    children: [
      {
        path: 'legacy/messages/:id',
        redirectTo: 'messages/:id'
      },
      {
        path: 'messages/:id',
        component: MessageCmp
      }
    ]
  }
]

When navigating to /legacy/inbox/33/legacy/messages/44, the router will first apply the outer redirect, transforming the URL to /inbox/33/legacy/messages/44. After that the router will start processing the children of the second route and will apply the inner redirect, resulting in this URL: /inbox/33/messages/44.

One constraint the router imposes is at any level of the configuration the router applies only one redirect...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime
Visually different images