参数...不是函数,未定义 [英] Argument ... is not a function, got undefined

查看:98
本文介绍了参数...不是函数,未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在玩AngularJS,但我收到一条错误消息:参数'Controller'不是函数,未定义这是JSFiddle 和HTML代码:

I'm playing with AngularJS, but I'm getting an error message: Argument 'Controller' is not a function, got undefined Here's the JSFiddle, and HTML code:

<h2>Hata's Tree-Like Set</h2>
<div ng-app ng-init="N=3;" ng-controller="Controller">
<input type="range" min="1" max="10" step="1" ng-model="N">  
<div class="tree"></div>
</div

然后我定义控制器函数,由于某种原因没有注册。

Then I define the Controller function in JavaScript, which is not registering for some reason.

function Controller($scope){
$scope.$watch("N", function(){  ... });}


推荐答案

我有完全相同的错误:参数'HelloCtrl'不是函数,未定义。

I had exactly the same error: argument 'HelloCtrl' is not a function, got undefined.

原来我的 hello.js 文件中有一个语法错误...数组定义中缺少逗号,在<$ c里面$ c> HelloCtrl()

Turns out I had a syntax error in my hello.js file... a missing comma in an array definition, inside HelloCtrl().

我添加了逗号,然后一切都开始工作了!

I added the comma, and then everything started working!

希望这会有所帮助。

这篇关于参数...不是函数,未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆