Heim > Fragen und Antworten > Hauptteil
下面这段代码:
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body ng-app="app">
<p ng-controller="MessageController">
{{message}}
</p>
<script src="../../angularv1.min.js"></script>
<script src="message-controller-scope.js"></script>
</body>
</html>
/**
* Created by Glacier on 2015/7/19.
message-controller-scope.js
*/
function MessageController($scope) {
$scope.message = "This is a model.";
}
显示结果是{{message}};应该显示是This is a model.
为什么显示不成功了?
仅有的幸福2017-05-15 16:55:54
孩子,你得angular对象都没有加载进去!!!
angular.module("app", []).controller("MessageController", function($scope){
$scope.message = "This is a model.";
});
世界只因有你2017-05-15 16:55:54
我想,问题可能出在
<script src="../../angularv1.min.js"></script>
这句,你看看路径是不是对的
如果angularJS能够引入,那么针对ng-app="app"是可以自己扫描运行的,那么{{message}}你看到的就不是{{message}}了,要么是'This is a model.',要么就是空白一片,要么就是console的报错.