<!DOCTYPE html>
<html ng-app="">
<head>
<title>hello</title>
<script type="text/javascript" src="lib/angular.js"></script>
</head>
<body>
<input type="text" ng-model="name">
<p>{{name}} </p>
</html>
我尝试做一个非常简单的角度项目,但有一些错误。在输出页面中出现变量名称,而不是预期的值。
答案 0 :(得分:0)
您需要声明模块和控制器,代码中缺少这两个,
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
});
<强>样本强>
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body ng-app="myApp" ng-controller="myCtrl">
<input type="text" ng-model="name">
<p>{{name}} </p>
<script>
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
});
</script>
</body>
</html>
&#13;
答案 1 :(得分:0)
检查样本angularjs代码
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
$scope.name = "Hello";
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body ng-app="myApp">
<div ng-controller="myCtrl">
<input type="text" ng-model="name">
<p>{{name}} </p>
</div>
</body>