Skip to content Skip to sidebar Skip to footer

Canjs Model Service Method Implementations

I am having trouble understanding how to correctly implement the can.Model service methods. I currently have this var Foo = can.Model({ findAll: 'GET /service/Editor.svc/foo', find

Solution 1:

The findAll etc. methods you are defining are constructor methods not prototype methods. That means that you have to call it on the Foo object and not the foo instance (I usually name my Model and instances of it differently as not to confuse them - e.g. var bar = new Foo()).

Foo.findAll({}, function(data) {

});

// Or a little nicer:
Foo.findAll({}).then(function(data) {

});

Post a Comment for "Canjs Model Service Method Implementations"