angularjs - Rails angular coffeescript error -


i'm using angularjs-rails gem. i've created angular_app folder in assets, , have angular_app/controllers/phonelistcontroller.js.coffee, , angular_app/modules/phonecatapp.js.coffee (*yeah you're right i'm doing angular's phone tutorial ). angular_app/controllers/phonelistcontroller.js.coffee has:

phonecatapp.controller 'phonelistcontroller', ($scope) ->   $scope.phones = [     { 'name': 'nexus s'       'snippet': 'fast got faster nexus s.'     }     {       'name': 'motorola xoom™ wi-fi'       'snippet': 'the next, next generation tablet.'     }     {       'name': 'motorola xoom™'       'snippet': 'the next, next generation tablet.'     }   ]   return 

angular_app/modules/phonecatapp.js.coffee has:

phonecatapp = angular.module('phonecatapp', []) 

every thing works fine if use vanila js in angular_app/modules/phonecatapp.js.coffee using `phonecatapp = angular.module('phonecatapp', [])`` (with backsticks).

so problem coffee covers in anonymous function ().call.this. should make work in coffee?

the problem, you've stated, the

(function() { ... }).call(this) 

that coffeescript compiler generates. make phonecatapp global do

this.phonecatapp = phonecatapp 

in angular_app/modules/phonecatapp.js.coffee file after angular.module() call.

however, better use:

angular.module('phonecatapp').controller( ... ) 

to define controllers. version gets angular provide module singleton on define controller.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -