9

I am able to make the phone clickable in this way:

<a href="tel:+1-800-555-5555">Call 1-800-555-5555</a>

However, I am to grabbing phone numbers from a database and I am not sure how to make the following that is grabbing the phone clickable:

    <strong>Phone:</strong> <i class="glyphicon glyphicon-earphone"></i> {{e.Phone | PhoneNumber}}

UPDATE

<div>
<nav class="hidden-xs visible-md visible-lg" ng-show="ShowResults"><uib-pagination boundary-links="true" max-size="maxPageNumbersToShow" ng-model="currentPage" total-items="resultsCount"> </uib-pagination></nav>

<nav class="visible-xs hidden-md hidden-lg" ng-show="ShowResults"><uib-pager ng-model="currentPage" total-items="resultsCount"> </uib-pager></nav>

<div class="container">
    <div id="searchResults" ng-repeat="e in providers" ng-show="ShowResults">
        <div class="row">
            <hr />
            <h4>{{e.FullName}}</h4>
        </div>

        <div class="row">
            <div class="col-md-4 no-margin padding"><strong>Specialty: </strong>{{e.Specialty}}<br />
                <span class="padding"><strong>Gender:</strong> {{e.Gender}}</span><br />
                <strong>Language(s):</strong> {{e.Languages}}</div>

            <div class="col-md-4 no-margin"><strong>Clinic: </strong> <i class="glyphicon glyphicon-map-marker"></i> <a href="https://maps.google.com?saddr=Current+Location&amp;daddr={{e.GoogleParams}}" target="_blank"> {{e.Address1}}</a><br />
                <span class="shiftAdd padding"><a href="https://maps.google.com?saddr=Current+Location&amp;daddr={{e.GoogleParams}}" target="_blank">{{e.Address2}}</a> </span><br />
                <strong>Phone:</strong> <i class="glyphicon glyphicon-earphone"></i> <a href={{e.Phone}}></a></div>
        </div>
    </div>
</div>
&nbsp;

<nav class="visible-xs hidden-md hidden-lg" ng-show="ShowResults">
    <hr /><uib-pager ng-model="currentPage" total-items="resultsCount"> </uib-pager></nav>

Update 2

Here is what I did to determine whether phone number should be clickable:

var probablyPhone = ((/iphone|android|ie|blackberry|fennec/).test(navigator.userAgent.toLowerCase()) && 'ontouchstart' in document.documentElement);

    function initialize() {
        (function($) {
            $('.call').css("text-decoration", "none");
            $('.call').css("color", "black");
            $('.call').css("cursor", "default");
        })(jQuery);
    }

and what is added to the tag:

<a href={{'tel:'+e.Phone}} onclick="return probablyPhone;">{{e.Phone | PhoneNumber}}</a>

Not sure why it isnt working

Any help wold be appreciated, thanks

2
  • <a href="e.Phone" >{{e.Phone | PhoneNumber}}</a>. After that depend what your dataset return. Commented Aug 22, 2016 at 21:07
  • I tried what you did and the numbers are clickable. However, nothing happens, meaning that the phone does not appear and shows the numbers pressed Commented Aug 22, 2016 at 21:12

3 Answers 3

13

Try

<a href={{'tel:'+e.Phone}}>{{e.Phone | PhoneNumber}}</a>
10
  • @ Lukasz Also, the decoratePhoneNumber prevents the number to appear and thank you for the link, I will look at it Commented Aug 22, 2016 at 21:26
  • 1
    What about <a href={{'tel:'+e.phone}}>{{e.phone | PhoneNumber}}</a> ?
    – Łukasz
    Commented Aug 22, 2016 at 21:29
  • and the scope you have appears it will also be clickable on desktop, how would I prevent that Commented Aug 22, 2016 at 21:30
  • What is displayed when you write just {{e.Phone}}?
    – Łukasz
    Commented Aug 22, 2016 at 21:32
  • Let us continue this discussion in chat.
    – Łukasz
    Commented Aug 22, 2016 at 21:36
5

For Angular 2+, try

<a [href]="'tel:' + e.Phone">{{ e.Phone }}</a>
1
  • Error: expected token Lexer Error: Unexpected character [] at column 1 in expression [tel:${customer.phone_landline}`]
    – kolypto
    Commented Mar 7, 2021 at 19:24
2

This was what worked for me: Angular 2+.

<a href="tel:{{e.Phone}}">{{ e.Phone }}</a>

Not the answer you're looking for? Browse other questions tagged or ask your own question.