請問為什么我的html顯示的是{{greeting.text}},Angular而不是Hello,Angular
<!DOCTYPE?html> <html?ng-app> <head> ????<meta?charset="UTF-8"> ????<title>Title</title> ????<script?src="js/angular.js"></script> ????<script?src="js/HelloAngular-MVC.js"></script> </head> <body> ????<div?ng-controller="HelloAngular"> ????????<p>{{greeting.text}},Angular</p> ????</div> </body> </html>
/*JS*/ function?HelloAngular($scope)?{ ????$scope.greeting?={ ????????text:'hello' ????}; }
版本是1.6請問如何解決
2017-07-06
<!DOCTYPE?html>
<html?ng-app>
<head>
????<meta?charset="UTF-8">
????<title>Title</title>
????<script?src="js/angular.js"></script>
????<script?src="js/HelloAngular-MVC.js"></script>
</head>
<body>
<div ng-app="myApp" ng-controller="HelloAngular">
? ? ? ? <p>{{greeting.text}},Angular</p>
? ? </div>
</body>
</html>
<script>
var app = angular.module("myApp", []);
app.controller("HelloAngular", function($scope) {
? ? $scope.greeting ={
? ? ? ? text:'hello'
}
});
</script>