adrianlee44 / ng-backbone Goto Github PK
View Code? Open in Web Editor NEWBackbone data model and collection for AngularJS
Home Page: http://adrianlee44.github.io/ng-backbone/
License: MIT License
Backbone data model and collection for AngularJS
Home Page: http://adrianlee44.github.io/ng-backbone/
License: MIT License
Thanks for the great wrapper!
How did you get it to work with filtering? For me it results in an endless loop (maximum call stack size exceeded, inside of the search of the angular filter). Which probably is due to the fact that filter tries to iterate every property of the object it's supposed to filter. In the case of Backbone models those properties are in some cases transitively self-referencing (model.collection, xhr,...). Any ideas?
How to create and get RelationShip beetwen models?
Sup bros @adrianlee44 @chemoish. I saw #6.
I played with options.cache = true
in ngBackbone.sync
which added the baked in $http caching… but I need more control, namely for invalidation and/or using a custom cache provider.
The biggest point of note is model.delete() calling collection.delete()
For success and error callbacks, you get the following arguments: (collection, response, options)
In the normal Backbone + $.ajax world, this callback function gets passed to $.ajax, where the first argument is data
(the data response from the server, parsed according to its dataType). Data then gets passed on to be the response
argument of our callback.
At the same time, the jqXHR object returned by $.ajax
gets assigned to options.xhr
, so you are able to look at the response code from there. In contrast with current ng-backbone, options.xhr
is just the promise returned by $http.
To make things more confusing, $.ajax
's error callback gets a jqXHR
for its first argument...so while backbone's docs say that both callbacks get the same arguments (collection, response, options)
, response is different for error...and you can grab the HTTP status code from it.
Would you accept a PR that exposes the HTTP status code in some way? What if we did something like this...
var xhr = ajax(_.extend(params, options)).
success(function(data, status, headers, config) {
options.xhr = {
status: status
headers: headers
config: config
}
if (!isUndefined(options.success) && _.isFunction(options.success)) {
options.success(data);
}
}).
error(function(data, status, headers, config) {
options.xhr = {
status: status
headers: headers
config: config
}
if (!isUndefined(options.error) && _.isFunction(options.error)) {
options.error(data);
}
});
options.xhr still wouldn't be an xhr object ($http doesn't give us that), but it would be a little bit closer. Currently options.xhr is just the same promise that already gets returned by the fetch
, create
, etc. functions.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.