Skip to content

Instantly share code, notes, and snippets.

@duanefields
duanefields / AngularController.coffee
Last active June 8, 2016 00:55
CoffeeScript Base Classes for AngularJS
module.exports = class AngularController
# register the subclass with angular, module and name are optional
@register: (name, module) ->
module ?= @module || angular.module 'controllers'
name ?= @name || @toString().match(/function\s*(.*?)\(/)?[1]
module.controller name, @
# inject the list of dependencies, as a list of Strings
@inject: (args...) ->