如何在angular html模板中指定替换url选项


<button color="dark" fill="outline"  [routerLink]="['/home']" size="medium"
>Click here to add some</button>

我应该如何传递替换URL选项,就像我们在TS文件

await this.router.navigate(['/profile'], { replaceUrl: true });

我自己通过查看angular路由的类型文件找到了它:)我是这样做的

<button color="dark" fill="outline" replaceUrl="true"   routerLink="['/home']" size="medium"
>Click here to add some</button>
<button replaceUrl="true" routerLink="/home">Click here to add some</button>

你不需要为replaceUrl和routerLink使用[],如果它们没有绑定,只是简单的值。

选择的答案是正确的,但现在在Angular中,你还需要绑定这些属性,即使是布尔值,像这样:

<button [replaceUrl]="true" [routerLink]="['/home']">Click here to add some</button>

最新更新