Hi Christophe,
Since you can only store strings within Web Storage, everything is parsed
into a JSON and that's why the functions were lost.
While function storing may be added as a new feature in the future, for the
time being the best bet is to store the collection (array of objects) you
retrieved from the backend into the Web Storage, not the `$resource` object
itself.
Hope this helps! :P
On Saturday, December 7, 2013 6:53:32 PM UTC+8, Christophe HOARAU wrote:
>
> Hi,
>
> This is really great.
>
> Could you please help me on storing ngresources with ngstorage? It works
> fine as long as I don't reload the full page. When retrieving a stored
> ngResource after a page refresh it does not restore functions so I can't
> use ngResource functions anymore like $save. But it works fine as long as I
> don't refresh the page. I really don't know why.
>
> Maybe I'm wrong to try to store ngResource, do you have another suggestion
> in order to be able to store data and then sync easily ?
>
> Thanks.
>
> On Sunday, July 21, 2013 4:28:56 AM UTC+4, Kay wrote:
>>
>> I've recently created a Web Storage module that I believe is the most
>> easy-to-use one to date. A typical example:
>>
>>
>> *JavaScript*
>>
>> $scope.$storage = $localStorage.$default({
>> x: 42});
>>
>> *HTML*
>>
>> <button ng-click="$storage.x = $storage.x + 1">{{$storage.x}}</button>
>>
>>
>> It's called *ngStorage* and can be found at
>> https://github.com/gsklee/ngStorage with more explanations and live
>> demos on Plunker.
>>
>> Any suggestions and tips for improvements are welcome =)
>>
>>
>> On Monday, October 22, 2012 1:49:09 AM UTC+8, Steve Shaffer wrote:
>>>
>>> I'm looking for the best way to use some form of client-side resource
>>> storage within an Angular.is application. My ideal would be that there was
>>> a built-in method of caching ngResources in IndexedDB/WebSQL/LocalStorage
>>> (auto-sniff-selected???) so that apps can run offline and automatically
>>> syncing them with the server when the connection comes back. (Basically
>>> what toggl.com does with LocalStorage)
>>>
>>> I don't know if this is officially "outside the scope" of Angular.js,
>>> but my gut feeling is that it would fit in nicely. In many applications,
>>> two-way data binding is only as useful as your ability to persist that
>>> data. And that's not usually that easy to do (unless you just round-trip
>>> everything).
>>>
>>> I'd be super interested in working on this with whoever else might be
>>> interested.
>>>
>>>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.