如何在angular2 +的'innerHTML'中使用routerLink代替锚标记中的href?

问题描述 投票:0回答:1

角度2 +中>

  1. 如果我使用href进行重定向,则它重新加载整个页面
  2. In .ts

this.htmlText = 'The validation window for <a href=\"http://localhost/nomination/">Innovator Mind</a> nominations is open now. Last date to review is 2020-Jan-25';

in HTML

<div [innerHTML]="htmlText "></div>
  1. 如果我使用routerlink
进行重定向,则routerlink不会获取渲染在html中。

In .ts

this.htmlText = 'The validation window for <a routerLink=\"http://localhost/nomination/">Innovator Mind</a> nominations is open now. Last date to review is 2020-Jan-25';

in HTML

<div [innerHTML]="htmlText"></div>

那么如何在不重新加载页面的情况下实现页面路由?

在angular 2+中,如果我使用href进行重定向,则会重新加载整个页面。在.ts中,this.htmlText ='Innovator Mind ...

javascript html css angular typescript
1个回答
0
投票

添加

© www.soinside.com 2019 - 2024. All rights reserved.