错误:[ng:areq]参数'ActsController'不是函数,未定义
Error: [ng:areq] Argument 'ActsController' is not a function, got undefined
我一直收到错误:错误:[ng:areq]参数"ActsController"不是函数,未定义。我见过其他几个人也有类似的错误,通常是因为打字错误。但我想我在任何地方都没有拼错控制器的名字。
顺便说一句,我正在使用Angular和Rails。
app.js
var controllers, snowball_effect;
snowball_effect = angular.module('snowball_effect', [
'templates',
'ngRoute',
'ngResource',
'controllers'
]);
snowball_effect.config([
'$routeProvider', function($routeProvider) {
return $routeProvider
.when('/', {
templateUrl: "static_pages/index.html",
controller: 'StaticPagesController'
})
.when('/acts/index', {
templateUrl: "acts/index.html",
controller: 'ActsController'
});
}
]);
controllers = angular.module('controllers', []);
controllers.controller("StaticPagesController", ['$scope', function($scope) {}]);
controllers.controller("ActsController", [
'$scope',
'$routeParams',
'$location',
'$resource',
function($scope,$routeParams,$location,$resource) {
$scope.acts = [
{
id: 1,
name: "Plant a Flower",
description: "Plant a flower in your garden or along the street."
inspires: 1
}
];
}]);
javascript/templates/acts/index.html
<div class="actions_body">
<h2>Listing Actions</h2>
<div ng-controller="ActsController" class="body">
<table class="row">
<thead>
<tr>
<th class="col-md-offset-1 col-md-2 active">
<label>Name</label>
</th>
<th class="col-md-4">Description</th>
<th class="col-md-2">Inspires</th>
<th colspan="2" class="col-md-2">Modify</th>
</tr>
</thead>
<tbody ng-repeat="act in acts">
<td class="col-md-offset-1 col-md-2">{{act.name}}</td>
<td class="col-md-4">{{act.description}}</td>
<td class="col-md-2">{{act.inspires}}</td>
<td><a href="#">Edit</a></td>
<td><a href="#">Delete</a></td>
</tbody>
</table>
<br>
<a href="#">New Action</a>
</div>
</div>
编辑:
现在我想起来了,我也遇到了另一个问题。每当我刷新页面时,主要部分都会消失。我想这个问题更多的是针对Rails/Angular的。
views/home/index.html.erb
<div ng-app="snowball_effect">
<div class="view-container">
<div ng-include="'layouts/index.html'"></div>
</div>
</div>
assets/javascript/templates/layouts/index.html
<div ng-include="'layouts/navigation.html'"></div>
<div ng-view class="view-frame animate-view"></div>
assets/javascript/templates/static_pages/index.html
<div class="body">
<div class="container">
<div class="introduction">
<h1>Welcome to Snowball Effect</h1>
</div>
<div class="body">
<h2>A social media platform that brings people together in a spirit of community service.</h2>
</div>
</div>
</div>
因此,在layout/index.html中,导航栏加载良好,但ng视图仅在第一页加载后加载。
index.html中是否包含app.js??
<script src="js/app.js"></script>
相关文章:
- 现有函数未定义
- jQuery$.post可以在chrome、safari中工作,但不能在FF中工作(声明成功回调函数未定义)
- AngularJS ng repeat显示原型函数未定义
- jQuery onclick 函数:未定义不是一个函数
- 函数未定义
- 为什么在jsfiddle中显示ReferenceError:函数未定义
- 函数未定义,实际定义时为
- 函数未定义的Javascript(Basic)
- ajax函数未定义
- 为什么window.onload函数未定义
- 模块模式:函数未定义
- 包含的javascript源代码通过PHP,onmousemove事件,函数未定义
- 单击链接时出现函数未定义错误
- AngularJS和Angular Snap:SSnap构造函数未定义
- 在Node.js中,从同一文件中的另一个函数引用一个函数会导致'ReferenceError:-函数-未定义
- symfony trick javascript函数未定义
- 不断获取JS函数未定义错误
- AngularJS HTTP 资源 - 响应函数未定义
- 函数未定义,参数格式
- JavaScript 中的函数未定义