Merge pull request #363 from glowing-bear/fixlocalstorage
localstorage: fix initial value setting
This commit is contained in:
commit
638aeb6697
1 changed files with 7 additions and 2 deletions
|
@ -1,3 +1,5 @@
|
|||
(function() {
|
||||
'use strict';
|
||||
|
||||
var ls = angular.module('localStorage',[]);
|
||||
|
||||
|
@ -97,8 +99,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));
|
||||
|
@ -110,3 +114,4 @@ ls.factory("$store",function($parse){
|
|||
};
|
||||
return publicMethods;
|
||||
});
|
||||
})();
|
||||
|
|
Loading…
Reference in a new issue