.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