Using plugins from Cordova Plugins Registry

I want to use this plugin directly pulled from online. But after adding it to my project how do I use it inside my controllers? ngCordova does not seem to support this plugin yet.

The git repo shows you how to use the plugin using plain javascript

Thanks for the link. So the usage will be no different for Ionic? Don’t I need to inject or take care of the Angular digest cycle?

.controller('MainController', function($scope){
   $scope.result = 'empty';
   var telephoneNumber = cordova.require("cordova/plugin/telephonenumber");
   telephoneNumber.get(function(result) {
        $scope.result = 'result = ' + result;
    }, function() {
        $scope.result = 'error';
    });
});

I dont understand how to use TelephoneNumberPlugin in Ionic project.

What I’ve done:

  1. myapp> ionic plugin add https://github.com/macdonst/TelephoneNumberPlugin.git

  2. Inside index.html (myapp\www\index.html)
    after string <script src="cordova.js"></script>
    i add string <script type="text/javascript" charset="utf-8" src="telephonenumber.js"></script>

  3. In file controllers.js i add

    try{
    var telephoneNumber = cordova.require(“cordova/plugin/telephonenumber”);
    }catch(e){
    alert(e);
    }

  • upload and deploy myapp in cloud (myapp> ionic upload)
  • sync and run myapp in Ionic View program (on my android telephone)

i get alert error: “ReferenceError: cordova is not defined

also i get error if try:

var telephoneNumber = window.cordova.plugins.telephonenumber;

or

var telephoneNumber = window.plugins.telephonenumber;
var telephoneNumber = cordova.plugins.telephonenumber;
var telephoneNumber = cordova.plugins;


How can i get telephone number? How use this plugin in ionic project?
Please show in simple example!?