Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/362.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript AngularJS UI路由器赢得';t无法识别模块上定义的控制器_Javascript_Angularjs_Controller_Angular Ui Router - Fatal编程技术网

Javascript AngularJS UI路由器赢得';t无法识别模块上定义的控制器

Javascript AngularJS UI路由器赢得';t无法识别模块上定义的控制器,javascript,angularjs,controller,angular-ui-router,Javascript,Angularjs,Controller,Angular Ui Router,我正在学习Angular,我正在尝试使用ui路由器设置控制器的状态。我有一个名为app.js的主模块,然后是基于不同内容的子模块 第一个子模块是diary.js。除控制器外,其他所有功能都与此控制器一起工作。状态在UI中工作,等等。当我直接在diary.js中创建控制器时(例如controller:function(){//stuff},它工作正常)。但是,当我尝试为日记状态包含一个已经定义的控制器时(就像当前编写的那样),我得到了以下错误(我无法发布整个错误,因为stackoverflow不允

我正在学习Angular,我正在尝试使用ui路由器设置控制器的状态。我有一个名为app.js的主模块,然后是基于不同内容的子模块

第一个子模块是diary.js。除控制器外,其他所有功能都与此控制器一起工作。状态在UI中工作,等等。当我直接在diary.js中创建控制器时(例如controller:function(){//stuff},它工作正常)。但是,当我尝试为日记状态包含一个已经定义的控制器时(就像当前编写的那样),我得到了以下错误(我无法发布整个错误,因为stackoverflow不允许我有那么多链接):

“错误:[ng:areq] errors.angularjs.org/1.2.23/ng/areq?p0=DiaryCtrl&p1=not%20ananuction%2C%20got%20未定义 错误(本机)

下面是DiaryCtrl.js(已定义的控制器)的代码


非常感谢您的帮助。如果您需要更多信息,请告诉我。

我很确定这是因为您在
日记Ctrl
中的注入(
$scope
&
$http
)不是字符串:

.controller('DiaryCtrl', [$scope, $http, function ($scope, $http)
应该是:

// Notice the added quotations around the scope and http injections in the array
.controller('DiaryCtrl', ['$scope', '$http', function ($scope, $http) {

你肯定包括了DiaryCtrl.js脚本吗?没有。就是这样。新手错误。谢谢!因为我没有在我的索引页上包括控制器。愚蠢的错误。但是你是对的,我应该在引号中包含这些,所以我也修复了它。谢谢。
.controller('DiaryCtrl', [$scope, $http, function ($scope, $http)
// Notice the added quotations around the scope and http injections in the array
.controller('DiaryCtrl', ['$scope', '$http', function ($scope, $http) {