title: ngCordova geolocation with ionic framework
body: <p>I am trying to use ngCordova geolocation with my ionic app. I did the following:</p>
  
  <p>1) Bower installed and included ngcordova.min.js in index.html</p>
  
  <p>2) Injected 'ngCordova' as a dependency in my angular app.module.</p>
  
  <pre><code>angular
  .module('app', ['ionic', 'ngCordova'])
  .run(runConfig);
  </code></pre>
  
  <p>3) Added the dependency in my controller</p>
  
  <pre><code>SomeController.$inject = ['$location', '$cordovaGeolocation',
                            '$ionicPlatform']
  </code></pre>
  
  <p>4) This is what my controller looks like:</p>
  
  <pre><code> (function() {
      'use strict';
  
    angular
      .module('app.submission')
      .controller('SomeController', SomeController);
  
    SomeController.$inject = ['$location', '$cordovaGeolocation', '$ionicPlatform'];
  
    function SomeController($location, $element, $cordovaGeolocation, $ionicPlatform) {
      var vm = this;
      vm.place = '';
      vm.address = {
        'latitude' : null,
        'longitude' : null
      }
  
      vm.initialize = initialize;
      vm.getAddress = getAddress;
  
      function initialize() {
         var input = (document.getElementById('location-search'));
         var searchBox = new google.maps.places.SearchBox((input));
      }
  
      function getAddress(){
        var posOptions = {timeout: 20000, enableHighAccuracy: true};
              $cordovaGeolocation.getCurrentPosition(posOptions)
              .then(function(position){
                  var lat  = position.coords.latitude
                  var long = position.coords.longitude
                  console.log('lat', lat);
                  console.log('long', long);
              }, function(error){
                  console.log('error:', error);
              });
      }
  
    }
  
  })();
  </code></pre>
  
  <p>5) Function getAddress() is called on ng-click of a button.</p>
  
  <p>while i test the app on a web browser (google chrome) I get the following error</p>
  
  <pre><code>TypeError: $cordovaGeolocation.getCurrentPosition is not a function
  at SomeController.getAddress (SomeController.js:29)
  at $parseFunctionCall (ionic.bundle.js:21044)
  at ionic.bundle.js:53458
  at Scope.$eval (ionic.bundle.js:23100)
  at Scope.$apply (ionic.bundle.js:23199)
  at HTMLButtonElement.&lt;anonymous&gt; (ionic.bundle.js:53457)
  at HTMLButtonElement.eventHandler (ionic.bundle.js:11713)
  at triggerMouseEvent (ionic.bundle.js:2863)
  at tapClick (ionic.bundle.js:2852)
  at HTMLDocument.tapMouseUp (ionic.bundle.js:2925)
  </code></pre>
  
  <p>Can someone help me here, what is wrong with my code? Is it supposed to work only on mobile devices? I tried on a android device and it didnt work.</p>