i trying persit ng-model key , trying retrive, not working when object working when ng-model string.
<!doctype html> <html> <head> <script data-require="angular.js@1.5.7" data- semver="1.5.7" src="https://code.angularjs.org/1.5.7/angular.js"></script> <link rel="stylesheet" href="style.css" /> <script src="script.js"></script> </head> <body> <div ng-app="myapp"> <input type="text" ng- model="sometext.something.firstname" persist="" /> </div> </body> </html>
plunkr here: http://plnkr.co/edit/qqaxrojsrzpk6u81j95j?p=preview
this question has great explanation: storing objects in html5 localstorage
the short answer need stringify objects want store in localstorage, aware there caveats stringifying js objects.
scope.$watch(model, function (value) { localstorage[key] = json.stringify(value); });
Comments
Post a Comment