Skip to content Skip to sidebar Skip to footer

How To Make A Contact's Phone Number Clickable To Call And To Send A Message In Ionic?

I cloned the ionic project from GitHub While the contact's phone number is not clickable to call and message. So for the index.html file line 39, I converted from

Copy

and in your view you need to add:

<ang-href=tel:{{user.phoneNumber}}class="button button-positive">Call me</a>

Solution 2:

Update:

I've just noticed it's (probably) an issue with loading data not the link itself. Would need to see your controller code to know more about why it's not populating the ng-href if it's not the issue below...

Previously:

Using the following href should be enough to trigger a call:

tel:' + number

Angular (which ionic sits on) doesn't like anything unusual going into an anchors href unless you tell it you want it to. See here:

http://forum.ionicframework.com/t/ng-href-tel-redirecting-to-call-with-empty-number/4567/2

The quickest fix, if you 'just' want it to work is this in your view:

<png-if="contact.phones.length > 0">{{contact.phones[0].type}} : <ahref="#"ng-click="triggerCall('{{contact.phones[0].value}}')">{{contact.phones[0].value}}</a></p>

and then in your controller:

$scope.triggerCall = function(number){
    document.location.href = 'tel:' + number
}

Post a Comment for "How To Make A Contact's Phone Number Clickable To Call And To Send A Message In Ionic?"