Issue with plugin method

  • In my index.html I have:
    ons.ready(function() {
    var navigator = document.getElementById(‘navigator’);
    var button = document.getElementById(‘push-button’);

          button.onclick = function() {
          alert('En Dev0 Ready');
          var watchID   = navigator.compass.getCurrentHeading( 
              function OK1(heading) {
              function onErr(e){
                     alert ('Error: ' + e.code);});
          alert('En Dev1 Ready');


    and I got an error Uncaught TypeError: Cannot call method ‘getCurrentHeading’ of undefined

    For sure, I have enabled the plugin “Device Orientation”

    Can you tell me what my stupid mistake is ?
    I’m rather lost.

  • How are you testing the app? Have you compiled the app with the plugin? Are you using Monaca Cloud, VisualStudio, or some other IDE?

Log in to reply