Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/377.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/Jade错误:参数';MyController';不是函数,未定义(平均值)_Javascript_Node.js_Angularjs_Pug - Fatal编程技术网

Javascript AngularJS/Jade错误:参数';MyController';不是函数,未定义(平均值)

Javascript AngularJS/Jade错误:参数';MyController';不是函数,未定义(平均值),javascript,node.js,angularjs,pug,Javascript,Node.js,Angularjs,Pug,我知道这个问题已经被问过好几次了,但我已经尝试过其他老年退休金计划的几种建议解决方案,但都没能解决这个问题,我希望得到一些澄清 我正在使用基本的平均待办事项列表应用程序()。在实现了一个简单的控制器之后,我遇到了“错误:参数'nameOfMyController'不是函数,未定义。” 这就是我所处的位置: app.js(样板文件) 我尝试过修改这里引用的内容,例如,将mean.controller添加到数组中,但这显然不是正确的方法,因为它告诉我模块不存在 这是我的taskController.

我知道这个问题已经被问过好几次了,但我已经尝试过其他老年退休金计划的几种建议解决方案,但都没能解决这个问题,我希望得到一些澄清

我正在使用基本的平均待办事项列表应用程序()。在实现了一个简单的控制器之后,我遇到了“错误:参数'nameOfMyController'不是函数,未定义。”

这就是我所处的位置:

app.js(样板文件)

我尝试过修改这里引用的内容,例如,将mean.controller添加到数组中,但这显然不是正确的方法,因为它告诉我模块不存在

这是我的taskController.js(我遵循的一个普通教程使taskController成为一个独立的函数,但我将它声明为一个构造函数,就像angular的文档所说的那样)

我还尝试了angular.module('mean.system').controller('taskController',function taskController($scope){…},结果相同

现在可以查看:默认值中包含ng应用程序。jade

!!! 5
  html(ng-app='mean', lang='en', xmlns='http://www.w3.org/1999/xhtml', xmlns:fb='https://www.facebook.com/2008/fbml', itemscope='itemscope', itemtype='http://schema.org/Product')
    include ../includes/head
    body
     ...
     include ../includes/foot
那么在index.jade中,我有:

extends layouts/default

block head
  script(type='text/javascript', src='/js/controllers/taskController.js')

block content
  section(data-ng-view)
  div.container(ng-controller="taskController", ng-init="setTodos( #{JSON.stringify(todos)} )")
  ...
  div.row(ng-repeat="todo in todos | filter:notDoneFilter")
    label.checkbox
      input(type="checkbox", ng-model="todo.done")
      | {{ todo.description }}
    span.datestring
      i {{ todo.due | date: 'MMM d, yyyy' }}    
  ...
  div.row(ng-repeat="todo in todos | filter:doneFilter")
    label.checkbox
      input(type="checkbox", checked="true")
        del {{ todo.description }}
      span.datestring
        i {{ todo.due | date: 'MMM d, yyyy' }}
foot.jade插件:

//AngularJS
script(type='text/javascript', src='/lib/angular/angular.js')
script(type='text/javascript', src='/lib/angular-cookies/angular-cookies.js')
script(type='text/javascript', src='/lib/angular-resource/angular-resource.js')

我不认为我遗漏了任何角度指令,控制器本身也应该可以工作,所以我假设这是一个基本的应用程序架构问题,我不理解如何将所有东西组合在一起。任何帮助都将不胜感激。

此错误主要发生在angularjs无法在任何模块中找到控制器时。当u意外地重新定义了模块。 就你而言,我明白了

window.app=angular.module('mean',['ngCookies','ngResource','ui.bootstrap','ui.route','mean.system','mean.articles']);

然后

var-mean=angular.module('mean',[]);

此语法重新定义了模块


使用
angular.module('mean')获取现有模块
没有第二个参数。

我现在遇到了这个问题。我尝试了上面所有的建议,但没有任何效果。然后,我将AngularJS从版本1.3.9-build.3746降级到版本1.2.8。这就是我使用beta版本得到的结果。

谢谢,我有两个问题。您正确识别的是第一个问题。使用angular.module('mean').controller('taskController',function taskController($scope){…}并删除模块的第二个定义解决了函数未定义错误。我的index.jade中也缺少空格/标识(ng repeat需要在ng controller/ng init声明中).两个都修好了,一切正常.你帮我省去了几个小时的痛苦.非常感谢。
extends layouts/default

block head
  script(type='text/javascript', src='/js/controllers/taskController.js')

block content
  section(data-ng-view)
  div.container(ng-controller="taskController", ng-init="setTodos( #{JSON.stringify(todos)} )")
  ...
  div.row(ng-repeat="todo in todos | filter:notDoneFilter")
    label.checkbox
      input(type="checkbox", ng-model="todo.done")
      | {{ todo.description }}
    span.datestring
      i {{ todo.due | date: 'MMM d, yyyy' }}    
  ...
  div.row(ng-repeat="todo in todos | filter:doneFilter")
    label.checkbox
      input(type="checkbox", checked="true")
        del {{ todo.description }}
      span.datestring
        i {{ todo.due | date: 'MMM d, yyyy' }}
//AngularJS
script(type='text/javascript', src='/lib/angular/angular.js')
script(type='text/javascript', src='/lib/angular-cookies/angular-cookies.js')
script(type='text/javascript', src='/lib/angular-resource/angular-resource.js')