Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.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/4/unix/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
Angularjs 全局作用域中的控制器构造函数不工作_Angularjs - Fatal编程技术网

Angularjs 全局作用域中的控制器构造函数不工作

Angularjs 全局作用域中的控制器构造函数不工作,angularjs,Angularjs,我在教程视频中看到了这个基本的AngularJS代码,它给出了预期的输出。但是当我在本地尝试相同的代码时,它不起作用,它将{{message}}显示为输出 <!DOCTYPE html> <html lang="en" ng-app> <head> <title></title> </head> <body> <h1 ng-controller="HelloWorldCtrl">{{m

我在教程视频中看到了这个基本的AngularJS代码,它给出了预期的输出。但是当我在本地尝试相同的代码时,它不起作用,它将
{{message}}
显示为输出

<!DOCTYPE html>
<html lang="en" ng-app>
<head>
    <title></title>
</head>
<body>
    <h1 ng-controller="HelloWorldCtrl">{{message}}</h1>
    <script src="Scripts/angular.min.js"></script>
    <script type="text/javascript">

        function HelloWorldCtrl($scope)
        {
            $scope.message = "First Run...";
        }

    </script>
</body>
</html>
错误:[ng:areq]

为什么相同的代码在不同的环境中表现不同?
有人能指出我这里缺少什么吗?

Angular将运行,它将自动引导(由于
ng app
属性),并希望找到名为
HelloWorldCtrl
的控制器(由于
ng controller=“HelloWorldCtrl”
)。但是这个控制器是在角度之后定义的,所以在执行的时候它不在那里


最简单的解决方案是更改脚本的顺序,即将代码放在angular1.3.rc2之前。

angular1.3.rc2中发生了一些变化!

我也犯了同样的错误。1.2.25工程:

由于Angular v1.3.0-beta定义的控制器构造函数在全局范围内是

是否可能
脚本/Angular.min.js
不存在?可能是重复的,我在我的项目中有
angular1.3.rc2
,使用稳定的版本,工作正常,谢谢……)这不是正确的答案,没有什么是“破产的”,这是他们想要声明的方式的改变。如果你这样做的话,老办法会奏效。。。看,它在工作吗。这意味着你应该能够设置一个设置,但我无法让它工作。
Argument 'HelloWorldCtrl' is not a function, got undefined