-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Have option to use either: ngResource or js-data model layer #19
Comments
Just as a reference for others, here's a good video about it. |
Just a question: By using js-data, we'd still have the model for forms, right? Like the todo.model.js. |
Yes, you can see it here. http://www.js-data.io/v1.8.0/docs/js-data-angular For me I can live without this js-data. I use Ember Data in a project and it over complicates things more so then some applications need. Would be nice for this to be an opt-in feature rather in a core feature. |
You don't have to define all properties of your model, but you can: http://www.js-data.io/v1.8.0/docs/dsdefineresource Here is how you can validate the model: http://www.js-data.io/v1.8.0/docs/schemata--validation Maybe that jgodi is right, and that the user should be able to choose if using js-data, ngresource, restangular... But the good of js-data is the abstraction layer so you can do powerfull things or change the way you store your data without impact on your services and controllers. |
For some reason the links are broken to me, I'll take a look when I get home. But I agree with the opt thing. For now, we could leave it between |
Droping from core. |
As mentioned in #16 "Bower dependencies", we should introduce an abstraction layer such as js-data.
The basic:
add bower dependency: js-data-angular
load the module 'js-data' in client app.js
configure the default behavior (by default use http://www.js-data.io/docs/dshttpadapter):
DSProvider.defaults.basePath = '/api';
DSProvider.defaults.idAttribute = '_id'; // for mongo-db
define resources and relations-ships:
DS.defineResource{
name: 'users'
});
use it anywhere:
DS.findAll('users').then(function (users) {
$scope.users = users;
});
The entities are cached by default so I love to use it in combination with web sockets to synchronize the cached collection with the server.
It could be a good idea to write a custom adapter to cover this case.
The text was updated successfully, but these errors were encountered: