Sunday, February 2, 2014

Angular JS controller inheritance

Something I didn't know in AngularJS is that controllers can inherit from one another. My team member Pieter pointed this out to me and I think it's going to be very useful for us.

We're building a bunch of screens that have quite similar functionality ( start with a GET, POST on save etc ). In normal JavaScript, one can use prototypical inheritance of course, but that's not as evident with the Angular dependency injection.

However, since controllers can inherit from each other, it is! Check out this question on StackOverflow: http://stackoverflow.com/questions/18461263/can-an-angularjs-controller-inherit-from-another-contoller-in-the-same-module



Next week we'll be doing some refactoring!

No comments:

Post a Comment