-
Notifications
You must be signed in to change notification settings - Fork 0
Coq Callbacks
Charly POLY edited this page Jun 12, 2014
·
2 revisions
var user, UserModel;
UserModel = Coq.factory({
$resource : resourceMock,
$beforeSave : function() {
return $q.reject('ERROR');
}
});
user = new UserModel({ name : "test" });
user.save().then(function () { /* ... */}, function (err) { console.error(err); });
Output
ERROR
$beforeSave
$afterSave(response)
$beforeDestroy
$afterDestroy(response)
$beforeUpdate
$afterUpdate(response)
$before*
callbacks have record context, so they can update this.$attributes
before passing to $resource
.