Javascript 定义基本角度应用程序时出现语法错误

Javascript 定义基本角度应用程序时出现语法错误,javascript,angularjs,Javascript,Angularjs,大家好,我是个新手。我开始用这个演示制作一个应用程序。我面临的问题是,我不知道如何解决我遇到的错误。我尝试了很多解决方案,但没有一个对我有效。这是我得到的错误 myapp.html:13 Uncaught ReferenceError: HelloController is not defined(anonymous function) angular.js:13550 Error: [ng:areq] http://errors.angularjs.org/1.5.5/ng/areq?p0=H

大家好,我是个新手。我开始用这个演示制作一个应用程序。我面临的问题是,我不知道如何解决我遇到的错误。我尝试了很多解决方案,但没有一个对我有效。这是我得到的错误

myapp.html:13 Uncaught ReferenceError: HelloController is not defined(anonymous function)
angular.js:13550 Error: [ng:areq] http://errors.angularjs.org/1.5.5/ng/areq?p0=HelloController&p1=not%20a%20function%2C%20got%20undefined
    at Error (native)
    at https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js:6:412
    at qb (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js:23:157)
    at Pa (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js:23:244)
    at https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js:89:77
    at O (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js:72:75)
    at n (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js:64:7)
    at g (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js:58:305)
    at g (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js:58:322)
    at https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js:57:455(anonymous function) @ angular.js:13550(anonymous function) @ angular.js:10225n.$apply @ angular.js:17334(anonymous function) @ angular.js:1749invoke @ angular.js:4665c @ angular.js:1747yc @ angular.js:1767ee @ angular.js:1652(anonymous function) @ angular.js:30863b @ angular.js:3166Qf @ angular.js:3456Pf.d 
这是我的密码

<!doctype html>
<html>
    <head>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js"></script>
    </head>
    <body ng-app>
        <div ng-controller="HelloController">
            <h2>Welcome {{helloTo.title}} to angular</h2>
        </div>
        <script>
            var myapp = angular.module("myapp" , [])

            .controller(HelloController , function($scope){
                $scope.helloTo = {};
                $scope.helloTo.title = "AngularJS";
            });
        </script>
    </body>
</html>

欢迎{{helloTo.title}}来到这里
var myapp=angular.module(“myapp”,[])
.controller(HelloController,函数($scope){
$scope.helloTo={};
$scope.helloTo.title=“AngularJS”;
});

请告诉我我做错了什么

您遗漏了控制器名称周围的引号,因此angular解析器将其视为另一个在页面/代码中找不到的变量

var myapp = angular.module("myapp" , [])

                .controller('HelloController' , function($scope){
                    $scope.helloTo = {};
                    $scope.helloTo.title = "AngularJS";
                });

为此,您需要按照以下要求进行更改

<body ng-app="myapp">
    <div ng-controller="HelloController">
        <h2>Welcome {{helloTo.title}} to angular</h2>
    </div>
    <script>
        var myapp = angular.module("myapp", [])

        .controller("HelloController", function ($scope) {
            $scope.helloTo = {};
            $scope.helloTo.title = "AngularJS";
        });
    </script>
</body>

欢迎{{helloTo.title}}来到这里
var myapp=angular.module(“myapp”,[])
.controller(“HelloController”,函数($scope){
$scope.helloTo={};
$scope.helloTo.title=“AngularJS”;
});

HelloController中缺少分配模块名和字符串引号。

请参阅HelloController周围的引号,以解决未定义HelloController的问题。但我遇到了此错误
错误:[ng:areq]