From 8df9a7bbc239233f5bce63e02792b8afbd92e8df Mon Sep 17 00:00:00 2001 From: Pascal Weiland Date: Mon, 8 Dec 2014 23:32:29 +0100 Subject: [PATCH] Add UMD Support --- ngStorage.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/ngStorage.js b/ngStorage.js index 5df0b5f..7bd7211 100644 --- a/ngStorage.js +++ b/ngStorage.js @@ -1,4 +1,14 @@ -(function() { +(function(angular, factory) { + 'use strict'; + if (typeof define === 'function' && define.amd) { + define('ngStore', ['angular'], function(angular) { + return factory(angular); + }); + } else { + return factory(angular); + } +}(typeof angular === 'undefined' ? null : angular, function(angular) { + 'use strict'; /** @@ -6,7 +16,7 @@ * @name ngStorage */ - angular.module('ngStorage', []). + angular.module('ngStorage', []) /** * @ngdoc object @@ -15,7 +25,7 @@ * @requires $window */ - factory('$localStorage', _storageFactory('localStorage')). + .factory('$localStorage', _storageFactory('localStorage')) /** * @ngdoc object @@ -24,7 +34,7 @@ * @requires $window */ - factory('$sessionStorage', _storageFactory('sessionStorage')); + .factory('$sessionStorage', _storageFactory('sessionStorage')); function _storageFactory(storageType) { return [ @@ -111,4 +121,4 @@ ]; } -})(); +}));