You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 9, 2021. It is now read-only.
Anton Isaykin edited this page Dec 5, 2015
·
9 revisions
modelFactory is a light-weight model layer that bridges the gap between some of the features that are common with SPA.
The idea is to encapsulate the logic for communicating with a single REST endpoint into a single Angular service or Model class. A new model is configured like
Within some other Angular component (like a service, controller, directive,...) you can then get a reference to the model
functionPersonController(PersonModel){varvm=this;vm.people=[];PersonModel.query().then(function(result){// you'll get a list of peoplevm.people=result;});}
The interesting part is that you'll not only get simple JavaScript objects back from the server, but they're being automatically wrapped as instances of PersonModel. This allows for further conveniences:
...
varsomePerson=vm.people[0];somePerson.name='Juri';// save it back to the serversomePerson.$save();
Interested? Then continue checking out our wiki articles for more details.