Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/402.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/7/wcf/4.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_Javascript_Angularjs - Fatal编程技术网

Javascript 首先看AngularJS

Javascript 首先看AngularJS,javascript,angularjs,Javascript,Angularjs,我正在尝试学习AngularJS,但我尝试的第一个示例不起作用。为什么?以下是HTML: <html ng-app> <head> <title></title> <script src="Scripts/angular.js"></script> <script src="app.js"></script> </head>`` <body ng-co

我正在尝试学习AngularJS,但我尝试的第一个示例不起作用。为什么?以下是HTML:

<html ng-app>
<head>
    <title></title>
    <script src="Scripts/angular.js"></script>
    <script src="app.js"></script>    
</head>``
<body ng-controller="MainCtrl">
    <div>Hello, {{userGroup.name}}!</div>
</body>
</html>
我会先重写你的控制器。从AngularJS 1.3开始,禁用全局控制器,请参阅:

$controller:使用全局控制器构造函数3f2232b5禁用

注册一个新的角度模块-使用名称。 更新ng应用程序指令


这是一个正在运行的演示-

错误是什么?什么版本的angular?我不认为你的HTML是有效的,它有``在和之间。除此之外,我们还需要看到错误消息或对不起作用的某些描述才能回答。很可能您使用的是最新的AngularJS版本。新版本不支持这样的控制器定义。谢谢你们,看起来这是个愚蠢的错误。是的,我看的课是一岁的
var MainCtrl = function ($scope) {
   $scope.userGroup = {
      name: "Kirill Kuts"
   };
}
angular.module('app', [])
  .controller('MainCtrl', function ($scope) {
   $scope.userGroup = {
      name: "Kirill Kuts"
   };
});