本文介绍了在定位标记点击时构建动态URL-Angular 5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有几个锚标签的表.我想在单击每个锚标记时动态创建一个外部URL.我尝试使用[routerLink],但它附加了基本URL.有什么角度的方法吗?非常感谢您的帮助.
I have a table of several anchor tags. I want to create an external URL dynamically on clicking each anchor tag. I tried using [routerLink] but it is getting the base URL appended. Is there any angular way of doing it ? Any help is much appreciated.
html
<ng-container matColumnDef="invoiceNo">
<mat-header-cell *matHeaderCellDef > Invoice # </mat-header-cell>
<mat-cell *matCellDef="let invoice">
<a [routerLink]="getInvoiceUrl()" target="_blank">
{{invoice.invoiceNumber}}
</a>
</mat-cell>
</ng-container>
ts
getInvoiceUrl(){
return "www.google.com";
}
推荐答案
public link ="public"
public link="public"
在标签中使用它-> [href] = link> {{link}}
use this in a tag --> [href]=link> {{ link }}
它将重定向到www.localhost:4200/public
It will redirect to www.localhost:4200/public
这篇关于在定位标记点击时构建动态URL-Angular 5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!