0
I need to create a directive but for the sake of organization I would like to do it in a class, but it’s making a mistake that I can’t identify. Here’s what I got:
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
find the following error:
Typeerror: Cannot read Property 'Compile' of Undefined
Inserted the function directly into the directive works, I’m doing something wrong or really the angular does not have this kind of support?
You can post the function generated in Javascript to
MyDirective
?– danguilherme
Thank you, I’ve found the answer
– Daniel