title: How to set active route link in Angular?
body: <p>I have the following link:</p>
  
  <pre><code> &lt;a routerLink="{{item._url}}" (click)="setActiveLink(i, item._url, menu)"
                  [routerLinkActive]="['is-active']"&gt;Link&lt;/a&gt;
  </code></pre>
  
  <p>How to extent <code>[routerLinkActive]</code> for custom URL to highlight link as active?</p>
  
  <p>I can use <code>ngClass</code> but how to get url to compare with my url?</p>
  
  <p>I did this:</p>
  
  <pre><code>&lt;a [ngClass]="{'is-active': isUrl()}" routerLink="{{item._url}}" (click)="setActiveLink(i, item._url, menu)"
                  [routerLinkActive]="['is-active']"&gt;{{item.title | translate}}&lt;/a&gt;
  </code></pre>
  
  <p>And method is:</p>
  
  <pre><code>public isUrl(): boolean {
      const currentUrl = this.router.url;
      const arrUrl = ['replacements'];
  
      for (let i = 0; i &lt; arrUrl.length; i++) {
        return currentUrl.indexOf(arrUrl[i]) &gt; -1;
      }
  
      return false;
    }
  </code></pre>
  
  <p>It  highlights all links in menu</p>