Use CoffeeScript's class in AngularJS directive controller -
I was using this approach while making AngularJS instructions with the coffee script:
< Code> angular Module 'MyApp', []). Directive 'Mary Directive', - & gt; Restrict: 'E' controller AS: 'ctrl' controller: - & gt; New class constructor: - & gt; @value = 3
This code works with coward 1.2.14 - but not with 1.3.0. I have no errors in the console, it just does not do anything, it appears that the controller is an empty object.
I answered almost the same question in this thread:. I like to keep my concurrent objects as a proper coffee script class. The key is to wrap new directive ()
inside a function block.
Class MyDirective constructor: (myService) - & gt; // Constructor content @ controller = microcontroller @ controller AS = 'ctrl' restricts: 'e' replaces: true field: attribute stuff: '=' link: (field, element, etter) - & gt; Angular Modules ('my_module') Director 'Directive Directive', (Mice Service) - & gt; New MyDirective (myService)
Comments
Post a Comment