2
.service ('storageManagement', function($http, Url, $window,$localStorage,$q)
{

   this.workTypeStorage=function()
   {
        var canceler = $q.defer();

        if (!$window.localStorage['ngStorage-workType'])
        {

            $http.post(Url.workType).success (function(response)
            { 
                $localStorage.workType = response;
                console.log( 'worktype created')
                canceler.resolve();


            }).error(function(err, status)
            {
                console.log (err)
            })

        }
    }

})

it works fine if the 'ngStorage-workType' exists.But if it doesn't exist, it keeps calling the URL and in between the calls i get the "$digest () iterations reached" error

noor
  • 651
  • 1
  • 8
  • 19
  • I know this question is old but it's worth directing users [here](https://stackoverflow.com/questions/13928057/how-to-cancel-an-http-request-in-angularjs) – JM-AGMS Dec 04 '18 at 22:14

0 Answers0