在锚标签点击时构建动态 URL - Angular 5 [英] Build a dynamic URL on anchor tag click - Angular 5

查看:21
本文介绍了在锚标签点击时构建动态 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆