Exact URL Matching in Angular

The routerLinkActive attribute actually checks the URL not for an exact match, but for a partial match. Let's say our links look like this:

app/app.component.html<nav>
  <a
    routerLink="/blog/"
    routerLinkActive="active"
  >
    Aaaa
  </a>
  <a
    routerLink="/blog/page/"
    routerLinkActive="active"
  >
    Bbbb
  </a>
</nav>

In this case, if we are at the url /blog/page/ both links will be styled.

You can force the check of link addresses for exact matches using the routerLinkActiveOptions attribute. See how to use it:

app/app.component.html<nav>
  <a
    routerLink="/blog/"
    routerLinkActive="active"
    [routerLinkActiveOptions]="{exact:true}">
      Aaaa
  </a>
  <a
    routerLink="/blog/page/"
    routerLinkActive="active"
    [routerLinkActiveOptions]="{exact:true}">
      Aaaa
  </a>
</nav>
Задание 1

Check that links are not set to exact matches by default.

Задание 2

Make links check for exact matches.