1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 2 2 2 6 | /*global angular */ /** * Services that persists and retrieves TODOs from localStorage */ angular.module('todomvc') .factory('todoStorage', function () { 'use strict'; var STORAGE_ID = 'todos-angularjs'; return { get: function () { return JSON.parse(localStorage.getItem(STORAGE_ID) || '[]'); }, put: function (todos) { localStorage.setItem(STORAGE_ID, JSON.stringify(todos)); } }; }); |