Skip to content

Instantly share code, notes, and snippets.

@thompson4822
Created June 24, 2013 20:00
Show Gist options
  • Save thompson4822/5853064 to your computer and use it in GitHub Desktop.
Save thompson4822/5853064 to your computer and use it in GitHub Desktop.
Defining AngularJS directives in CoffeeScript
@angular.module('HelloApp', ['components'])
@angular.module('components', [])
.directive('testElem', ->
restrict: 'A'
template: '<div class="my-directive-class"><h1>Hello...</h1><p ng-repeat="obj in arr">{{obj}}</p></div>'
link: (scope, iterStartElement, attr) ->
$(".my-directive-class").css({ 'background-color': 'yellow'})
scope.arr = ["Steve", 'is', 'the', 'beast']
)
.directive('helloWorld', ->
restrict: 'E'
scope:
name: '@name'
templateUrl: 'assets/html/partials.html'
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment