Have you watched NG-Cordova ?
first add ng-cordova to your project:
bower install ngCordova or <script src="lib/ngCordova/dist/ng-cordova.js"></script> <script src="cordova.js"></script>
Then enter:
angular.module('myApp', ['ngCordova'])
Here is a plugin that you could try: http://ngcordova.com/docs/plugins/backgroundGeolocation/
just install the plugin:
cordova plugin add https:
then tie it to the controller:
module.controller('MyCtrl', function($scope, $cordovaBackgroundGeolocation) { var options = { // https://github.com/christocracy/cordova-plugin-background-geolocation#config }; document.addEventListener("deviceready", function () { // `configure` calls `start` internally $cordovaBackgroundGeolocation.configure(options) .then( null, // Background never resolves function (err) { // error callback console.error(err); }, function (location) { // notify callback console.log(location); }); $scope.stopBackgroundGeolocation = function () { $cordovaBackgroundGeolocation.stop(); }; }, false); });
source share