Issue with plugin method



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

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


    </script>

    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