我无法弄清楚为什么我的控制器和模块没有像我一起学习的教程那样绑定。我使用的是Brackets程序,它提供了我的代码的实时预览,而不是显示$ scope.message,它只显示单词{{message}}。我刚刚开始学习angularjs。在文档的头部,我使用脚本标记和src =“https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js” 这里是body ... Angular.js绑定(简单的html文档)
您已成功地到达我的HTML文档!
<div ng-app="myModule" ng-controller="myController">
<!h5 tag contains a binded expression>
<h5> {{message}} </h5>
<ul>
<li ng-repeat="x in cars"> {{x}} </li>
</ul>
</div>
<!Create a module named 'myModule'Create controller named 'myController'>
<script>
var myApp =angular.module("myModule",[]);
myApp.controller("myController", function ($scope){
$scope.cars = ["BMW", "Toyota", "Ford", "Range Rover"];
$scope.message = "My students are the best in the world!";
})
</script>
</body>
是否当您在浏览器甚至'文件打开它的工作? – pr0gramist
我觉得你可能会遇到错误。你有没有在控制台中看到任何东西? – 1252748
它显示{{message}},但在教学视频中,他的浏览器显示实际的信息“我的学生是世界上最好的!”我正在复制他的代码行,并使用与所建议的相同的程序“Brackets”。 –