0

i want to start background service when app is launch and after restart the service is automatically start

document.addEventListener('deviceready', function() {
   myService = cordova.plugins.myService;;
  upload();
},

true);

  • Possible duplicate of [Run service when Ionic/Cordova app when it's closed](http://stackoverflow.com/questions/33111968/run-service-when-ionic-cordova-app-when-its-closed) – Tirthraj Barot Jun 16 '16 at 08:45

1 Answers1

0

you will need this service injected to your controller

.controller('myCtl', myCtl);

function myCtl(LoginService) {

   $scope.username = null;
   $scope.password = null; 

   $scope.doLogin = LoginService.loginUser;

}

and then in your view

<div ng-controller="myCtl">
   ...

   <input type="text" ng-model="username">
   <input type="password" ng-model="password">

   <button type="button" ng-click="doLogin(username, password)">
      Login
   </button>

   ...
</div>
matt93
  • 368
  • 4
  • 15
  • i will work on sync data from mobile to server automatically in some interval so i will run background process to sync data which is call periodically. – user3442057 Jun 17 '16 at 06:34