Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/21.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,并且正在学习教程。出于某种原因,它显示的是{{name}},而不是我在下面的代码中给出的名称 index.html <!doctype html> <html ng-app="myApp"> <head> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"> </scrip

我刚刚开始学习AngularJS,并且正在学习教程。出于某种原因,它显示的是{{name}},而不是我在下面的代码中给出的名称

index.html

<!doctype html>
<html ng-app="myApp">
    <head>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"> </script>
        <script src="js/main.js"> </script>
    </head>
    <body>
        <div ng-controller="MyController">
            {{ name }}
        </div>
    </body>
</html>

我看到的错误是,您将)放置在控制器的错误位置。尝试使用以下命令

var app = angular.module('myApp', []);

app.controller('MyController', function($scope) {
$scope.name = "Hello World!";
});

你检查控制台了吗?你一定有什么问题,需要更多的细节。你是如何开始申请的?您正在打开index.html文件吗?删除一次在
($scope)
之后添加的额外
,并在
}
之后添加它。为
MyController
和分号定义的
函数的语法错误!谢谢,成功了!
var app = angular.module('myApp', []);

app.controller('MyController', function($scope) {
$scope.name = "Hello World!";
});