3

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" />
Cadmos
  • 277
  • 4
  • 21
  • Those functions have nothing to do with AngularJS, use `onclick` instead or call them from an Angular controller. – Fran Dios Apr 07 '15 at 02:22

3 Answers3

1

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! :)

0

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.

John Gonzalez
  • 315
  • 2
  • 11
0

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>
Leogreen
  • 701
  • 1
  • 6
  • 20