I want to run a service only at the time of first time launch?

I want to use a service only for first time launch of application in a device. After that i want to use localStorage for data changes n all. Is their any function by which I can call a service only once to store data in localStorage ? I don’t want to run this service again.

Ex code
app.controller(‘TodoCtrl’, function($scope,$http,$state, $stateParams,$filter) {

   $http.get('js/data.json').success (function(data){
    window.localStorage['post'] = JSON.stringify(data);

  $scope.tasks = JSON.parse(window.localStorage['post']);

if you can get many data with your request --> do not store the data in localstorage!

But you can check before you send the request, if there is a key in the localstorage --> if so use that data --> in other caaes load them before

How to use that key for localStorage data?

the localstorage comes with some build in methods, that should be used:

window.localStorage.getItem()
window.localStorage.setItem()
window.localStorage.removeItem()