In my Angular component, I have successfully added an anchor element like this:
<a [routerLink]="['/LoggedIn/Profile']">Static Link</a>
Clicking the link navigates to the desired component without any issues.
Now, I want to incorporate a similar dynamic link. Within my app, there is a "notification component" dedicated to displaying notifications.
The notification component looks something like this:
<div [innerHTML]="notification.content"></div>
Here, notification.content
is a public string variable within the NotificationComponent
class that holds the HTML content to be displayed.
The notification.content
can include:
<div>Click on this <a [routerLink]="['/LoggedIn/Profile']">Dynamic Link</a> please</div>
While the dynamic link appears correctly on the screen, it does not function when clicked.
Is there a way to make the Angular router work with dynamically generated links like this?
PS: I am aware of DynamicComponentLoader
, but I require a more flexible solution where various types of HTML content, including different kinds of links, can be sent to my notification component.