title: Angular2 Router - conditionally hide links
body: <p>Is there a way to conditionally hide a router-link in Angular2?</p>
  
  <p>For example, I have the following code;</p>
  
  <pre><code>&lt;li&gt;&lt;a [routerLink]="['RegisterUser']"&gt;Register User&lt;/a&gt;&lt;/li&gt;
  </code></pre>
  
  <p>I want to hide the link when the user is logged in.  </p>
  
  <p>On my component, I use the <code>@CanActivate</code> decorator to determine if the route can be activated, but this doesn't hide the link itself.</p>
  
  <pre><code>@CanActivate(() =&gt; hasValidToken())
  </code></pre>
  
  <p>I <em>could</em> use the <code>*ngIf</code> structural directive with the <code>hasValidToken()</code> method (which returns a boolean) but this seems heavy handed and a bit dirty.</p>
  
  <pre><code>&lt;li&gt;&lt;a [routerLink]="['RegisterUser']" *ngIf="!hasValidToken()"&gt;Register User&lt;/a&gt;&lt;/li&gt;
  </code></pre>
  
  <p>Is there a cleaner way to approach this?</p>
  
  <p>Thanks</p>