Javascript 轨道上的角度JS-参数';拉斐尔';不是函数,未定义

Javascript 轨道上的角度JS-参数';拉斐尔';不是函数,未定义,javascript,html,ruby-on-rails,angularjs,Javascript,Html,Ruby On Rails,Angularjs,下面是关于RoR项目的整数角度JS的教程 在我的控制器js文件中,我有以下内容: 抽奖。咖啡 # Place all the behaviors and hooks related to the matching controller here. # All this logic will automatically be available in application.js. # You can use CoffeeScript in this file: http://coffeescri

下面是关于RoR项目的整数角度JS的教程

在我的控制器js文件中,我有以下内容:

抽奖。咖啡

# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

@RaffleCtrl = ($scope) ->
    $scope.entries = [  

        {name:"name1"}
        {name:"name2"}
        {name:"name3"}
        {name:"name4"}
    ] 
在我的控制器html(由rails生成)中,我有:

index.html.erb

<h1>Raffle</h1>

<div ng-controller="RaffleCtrl">
    <form>
        <input type="text" ng-model="newEntry.name">
    </form>

    <ul>
        <li ng-repeat="entry in entries">
            {{entry.name}}
        </li>
    </ul>
</div>
抽奖
  • {{entry.name}
因此,它应该重复数组项中的四个名称,但它不起作用:我打开日志,发现以下错误:

参数“RaffElectrl”不是函数,未定义

必须在
application.html.erb
中定义指令:

<html ng-app="Raffler">
...
</html>
为此:

angular.module('Raffler', []).controller "RaffleCtrl", ($scope) ->
您必须在Angular apps中设置必需的
ng app
指令——这将元素指定为根元素。在应用程序布局中,在诸如body或html标记之类的高级/根元素上执行此操作。重要提示,您可以指定此指令一次,也只能指定一次——如果您错误地添加了多个指令,那么应用程序中的第一个指定将用于定义根元素

添加ng app后,使用在
ng app
中指定的名称指定匹配的根模块。在定义中保留数组为空表示您正在定义模块而不是调用它。不管你使用什么名称,只要确保它是对你的应用程序的相对描述,在你的模块中是唯一的,并且你为根模块指定的名称与你在“ng应用程序”中添加的名称完全相同。此模块将直接包含您的应用程序代码,或者依赖于包含它的其他模块

基本上,您必须为应用程序提供一个
ng app
属性,指定文档的根元素。然后你必须用相同的名字创建你的角根模块,在本例中是“Raffler”

这应该是相关的,但FWIW I使用的是Rails'4.1.5'和angularjs Rails gem 1.4.4

angular.module('Raffler', []).controller "RaffleCtrl", ($scope) ->