0

I'm trying to put a routerLink within in a const but it doesn't work.

const str4 = `<div `+knowmore_style+`>
  <b><a routerLink="/details/` + entry._id + `">
  <img src="assets/icon/add.png" alt="ques-mark" style="width:1em; filter:invert(1)">
  Know More


  </a></b>

The button is only clickable when I put like this :

const str4 = `<div `+knowmore_style+`>
  <b><a href="/details/` + entry._id + `">
  <img src="assets/icon/add.png" alt="ques-mark" style="width:1em; filter:invert(1)">
  Know More


  </a></b>

Do you know guys how to do? Thanks in advance

  • Because HTML is supposed to be generated (and compiled) by the template, not by the TypeScript code. – JB Nizet Nov 22 '18 at 15:53
  • why would you do that? – itdoesntwork Nov 22 '18 at 15:56
  • Please add details like why exactly are you trying to implement it in this way, what exactly are you trying to achieve here and whether you have added the `RouterModule` to the `imports` array of your `@NgModule` – SiddAjmera Nov 22 '18 at 16:13

1 Answers1

0

Would this work by chance?

<a routerLink="['/details/', entry._id]"></a> 
Mark B
  • 415
  • 4
  • 13