Cordova hello world plugin not working


#1

I’m a begginer in cordova and ionic development.
I try to write a simple cordova plugin and use that in ionic project.
I use this plugin.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
  id="company.com.app.functions"
  version="1.0.0">

    <name>helloWorld</name>
    <author>author name</author>
    <js-module src="www/functions.js" name="device">
        <clobbers target="device" />
    </js-module>form>
</plugin>

and this is my functions.js:

exports.getData = function() {
    return 'plugin test';
  };

and try to call my plugin function from ionic and angular controller:

$scope.callFunc1 = function () {
    alert(device.data.getData());
    // and also try below code:
    // alert(cordova.plugins.data.getData());
    // and also try below code:
    // alert(window.data.getData());
  };

but no alert() message display in my page.

I also try to use this plugin. Install used this command:

cordova plugin add https://github.com/domaemon/org.apache.cordova.plugin.helloworld.git

and use this code to call helloWorld function:

$scope.callFunc1 = function () {
        navigator.helloworld.say();
      };

and also test this:

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {

    navigator.helloworld.say();

    // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
    // for form inputs)
    if(window.cordova && window.cordova.plugins.Keyboard) {
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
    }
    if(window.StatusBar) {
      // org.apache.cordova.statusbar required
      StatusBar.styleDefault();
    }
  });
})

but no alert() message display in my page and I got this error in firebug:

Error: navigator.helloworld is undefined ....

what is the problem??

Thanks for your attentions.
Link to this question in stackoverflow is here.