最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - In angular 4how to use tel: in a *ngHref - Stack Overflow

programmeradmin1浏览0评论

I am using angular 4 and in template (.html), I coded as

<a *ngHref="tel:{{orders.billing_address.telephone}}"> <span> Call : </span>

It throws an error as

Can't bind to 'href' since it isn't a known native property a

I search it and get angular 4 use [routerLink]. But I don't know how to use [routerLink] to set tel: numbers. Could you please guide me.

I am using angular 4 and in template (.html), I coded as

<a *ngHref="tel:{{orders.billing_address.telephone}}"> <span> Call : </span>

It throws an error as

Can't bind to 'href' since it isn't a known native property a

I search it and get angular 4 use [routerLink]. But I don't know how to use [routerLink] to set tel: numbers. Could you please guide me.

Share edited Sep 15, 2017 at 13:12 mxr7350 1,4583 gold badges22 silver badges30 bronze badges asked Sep 15, 2017 at 13:06 Tamil Selvan CTamil Selvan C 20.3k12 gold badges54 silver badges71 bronze badges 1
  • Please visit angular.io/api/router/RouterLink – Ramesh Rajendran Commented Sep 15, 2017 at 13:15
Add a ment  | 

2 Answers 2

Reset to default 4

Just href inside []. It will let you to remove {{}} part. And if you want to concatenate strings inside, you need to create a string like 'tel:' + otherParts

<a [href]="'tel:' + orders.billing_address.telephone"> <span> Call : </span>

use the [href] in angular 2

<a [href]="'tel:'+ orders.billing_address.telephone"> <span> Call : </span>
发布评论

评论列表(0)

  1. 暂无评论