Cadmos
Cadmos

Reputation: 267

Onsen-UI how to dial with ng-click inside <ons-button>

I am trying to make an ons-button using ng-click to dial a number when it is clicked, in both iOS & Android. I use Cordova framework.

I have used the followings but with no success:

    <ons-button ng-click="window.open('tel: {{69000000}}', '_system')">Call</ons-button>
    <ons-button ng-click="window.location.href('tel: {{69000000}}', '_system')">Call 2</ons-button>

In config.xml I have enabled

    <access origin="tel:*" launch-external="yes" />

Upvotes: 3

Views: 1325

Answers (3)

Leogreen
Leogreen

Reputation: 701

I've found a way to call , very easy!

 <ons-button style="font-size: 24px;" modifier="large"       onclick="window.open('tel: {{69000000}}', '_system')">Call</ons-button>

Upvotes: 0

John Gonzalez
John Gonzalez

Reputation: 315

I was actually using a href for a long time, but that causes a bunch of css trouble. I found this plugin to be a big help putting the dialer in a ons-button.

https://build.phonegap.com/plugins/328

In my js I had

$scope.dial = function(){

        phonedialer.dial(
                "9561234567", 
                 function(err) {
                 if (err == "empty") alert("Unknown phone number");
                 else alert("Dialer Error:" + err);    
                },
              function(success) { alert('Dialing succeeded'); }
             );
    }

and in my html I had

<ons-button style="font-size: 24px;" modifier="large" ng-click="dial()">Phone</ons-button>

alternatively, you can adjust the alerts, or remove them all togeter.

Upvotes: 0

Antonio Herreros
Antonio Herreros

Reputation: 11

I had the same problem, and in my case, I inserted a simple href. For example,
<a href="tel:123456789">123456789</a>
Hope this helps! :)

Upvotes: 1

Related Questions