title: Adding routerLink to anchor tag dynamically based on if a router link is passed to component
body: <p>I am trying to add <code>routerLink</code> to an anchor tag dynamically based on if a <code>routerLink</code> is passed to the component itself.</p>
  
  <p>This is the code I currently have:</p>
  
  <pre><code>[attr.routerLink]="router ? router : null"
  </code></pre>
  
  <p>The resulting markup looks like this when a <code>routerLink</code> is passed, but no <code>href</code> is passed:</p>
  
  <pre><code>&lt;a _ngcontent-hlo-122="" routerlink="/myRoute"&gt;My Link&lt;/a&gt;
  </code></pre>
  
  <p>I've tried this out a number of ways, but I can never seem to get this to work. Does anyone have a solid solution to this problem?</p>