mircobabini
10/25/2014 - 4:29 PM

Set of Commodities for IonicFramework

Set of Commodities for IonicFramework

/**
 * Set of Commodities for IonicFramework
 * @version 1.0.1
 * 
 * @author github.com/mircobabini
 * @license GPLv2
 */
angular.module('starter.Commodities', [])
.factory('Models', function(Artist, Gallery, Picture){
	return {
		Artist:  Artist,
		Gallery: Gallery,
		Picture: Picture
	}
})
.factory('Ionics', function($timeout, $location, $ionicModal, $ionicPopup, $ionicLoading, $ionicScrollDelegate){
	return {
		$timeout: 	$timeout,
		$location: 	$location,
		$modal: 	$ionicModal, 
		$popup: 	$ionicPopup,
		$loading: 	$ionicLoading, 
		$scroller: 	$ionicScrollDelegate, 
	}
})
.factory('Utils', function($state, $stateParams, $localstorage){
	return {
		$state: $state,
		$params: $stateParams,
		$localstorage: $localstorage,
		dummy: function(foo, bar){
			if(foo){
				return bar;
			}

			return false;
		}
	};
})
.factory('$localstorage', ['$window', function($window){
	return {
		set: function(key, value){
			$window.localStorage[key] = value;
		},
		get: function(key, defaultv){
			return $window.localStorage[key] || defaultv;
		},
		setObject: function(key, value){
			$window.localStorage[key] = JSON.stringify(value);
		},
		getObject: function(key){
			return JSON.parse($window.localStorage[key] || '{}');
		},
		remove: function(key){
			$window.localStorage.removeItem(key);
		}
	}
}])