I need to create a directive but for the sake of organization I would like to do in a class, but it is giving an error that I can not identify. What I have is the following:
My class:
class MyDirective
restrict: "E"
replace: true
scope:
myVar: '='
template: "<div>{{ myFunction(myVar) }}</div>"
link: (scope, element, attrs, form)->
scope.myFunction = (val)->
//do something
return 'my content'
My app:
myApp = angular.module('myApp', [ 'ngRoute', 'ngResource'])
myApp.directive "mydirective", MyDirective
I encounter the following error:
TypeError: Can not read property 'compile' of undefined