bfanger / angular-activerecord

A model layer for AngularJS inspired by Backbone.Model
MIT License
137 stars 28 forks source link

$beforeSave & $afterSave: perform logic before and after $save method #23

Closed reneras closed 9 years ago

reneras commented 9 years ago

Loving ActiveRecord so far! It's usually my defacto solution for modelling with REST api's.

The reason for this pull request is, I ran into a lot of code duplication of behaviour in controllers while working on a very large app. Which could easily be in one place: the model. Let's say you would like to show one and the same modal every time when an activerecord model fails to save. Just implement the $afterSave method and on certain error codes just call the modalService and you're good to go.

If something needs to be refactored or elaborated about please let me know.

Rene