Two questions:
1) I am using angular -js and I am looking for a way to model my data. I have experience with the idea of a model in the spine. Is this a factory in angular? Is it a “best practice” to have many factories (one for each type of model), basically mimicking a “class” using “factory”?
Does the factory represent my model with some "helper" functions (for example, a model on the Backbone), or does my factory represent a list of members (for example, collection on the trunk)?
2) For example, let them say that I want to create objects to map to REST resources, and I have a "member" resource, which I get with GET-ing: / members / 123. This returns a json object with various fields. Sort of:
{id: 123, name: 'angularjs', date_created: 1235845}
Now I want some view in my AngularJS application of this member object. This view is more than just matching fields - I want to add “helper” functions, for example, a function that converts a date_create field to something human-readable.
How to present it? using factory + $ resource
source
share