angularjs遵循MVC模式,慣例來一個hello world吧
代碼如下:
<html ng-app>
<head>
<script type="text/javascript" src="angular.min.js"></script>
<script type="text/javascript" src="controllers.js"></script>
</head>
<body>
<div ng-controller='HelloController'>
<p>{{greeting.text}}, world</p>
</div>
</body>
</html>
controllers.js中的內容
代碼如下:
function HelloController($scope) {
$scope.greeting = { text: "Hello"};
}
MVC寫起來很不錯的感覺~~