我正在使用angularjs-rails gem。 我已經在資產中創建了angular_app文件夾,並且有angular_app/controllers/phoneListController.js.coffee和angular_app/modules/phoneCatApp.js.coffee(*是的,你說的對,我正在做angular的電話教程)。所以angular_app/controllers/phoneListController.js.coffee
有:Rails angular coffeescript error
phonecatApp.controller 'PhoneListController', ($scope) ->
$scope.phones = [
{ 'name': 'Nexus S'
'snippet': 'Fast just got faster with Nexus S.'
}
{
'name': 'Motorola XOOM™ with Wi-Fi'
'snippet': 'The Next, Next Generation tablet.'
}
{
'name': 'MOTOROLA XOOM™'
'snippet': 'The Next, Next Generation tablet.'
}
]
return
angular_app/modules/phoneCatApp.js.coffee
有:
phonecatApp = angular.module('phonecatApp', [])
,如果我使用'phonecatApp = angular.module使用vanila JS在angular_app/modules/phoneCatApp.js.coffee
每一件事情正常工作( 'phonecatApp',[])``(帶後槓)。
所以問題是,咖啡涵蓋所有與匿名函數().call.this。我應該怎麼做才能使它在咖啡中工作?
in angular_app/controllers/phoneListController.js.coffee好像你沒有添加$ scope作爲依賴。這行應該是:phonecatApp.controller'PhoneListController','$ scope',($ scope) - > ... – Jax 2015-04-01 08:55:15
不起作用:phonecatApp未定義 – ClassyPimp 2015-04-01 08:58:02
您是否有index.js.coffee文件,您聲明要包含在您的項目中的文件? – Jax 2015-04-01 09:02:28