From a7a8d60aeaf4a1cc73e0523488f27c35a4d8815b Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Wed, 16 Jul 2014 20:34:50 +0200 Subject: [PATCH] localstorage: fix initial value setting --- js/localstorage.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/js/localstorage.js b/js/localstorage.js index cfcf1ce..44893b1 100644 --- a/js/localstorage.js +++ b/js/localstorage.js @@ -1,3 +1,4 @@ +'use strict'; var ls = angular.module('localStorage',[]); @@ -97,8 +98,10 @@ ls.factory("$store",function($parse){ * @returns {*} - returns whatever the stored value is */ bind: function ($scope, key, def) { - def = def || ''; - if (publicMethods.get(key) === undefined) { + if (def === undefined) { + def = ''; + } + if (publicMethods.get(key) === undefined || publicMethods.get(key) === null) { publicMethods.set(key, def); } $parse(key).assign($scope, publicMethods.get(key));