Skip to content

Instantly share code, notes, and snippets.

@kurtsson
Last active August 29, 2015 14:08
Show Gist options
  • Save kurtsson/3a2ca2e509b31c6362a4 to your computer and use it in GitHub Desktop.
Save kurtsson/3a2ca2e509b31c6362a4 to your computer and use it in GitHub Desktop.
Custom Angular directive in CoffeeScript, the proper way
class MyDirective
constructor: (myService) ->
@controller = MyController
@controllerAs = myCtrl
restrict: 'E'
replace: true
scope:
attributeStuff: '='
link: (scope, element, attr) ->
// Link stuff
angular.module('my_module').directive 'MyDirective', (myService) ->
new MyDirective(myService)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment