AngularJS 应用

AngularJS模块(Module)定义了AngularJS的应用。

AngularJS控制器(Controller)用于控制AngularJS应用。

ng-app指令定义了应用,ng-controller指令定义了控制器。

AngularJS实例:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="X-UA-Compatible"content="IE=edge" />
<meta name="viewport"content="width=device-width,initial-scale=1" />
<title></title>
<meta charset="utf-8" />
<link rel="stylesheet"href="bootstrap-3.3.5/dist/css/bootstrap.min.css" />
</head>
<body>
<div class="container">
<div data-ng-app="myApp"data-ng-controller="myCtrl">
名:<input type="text"data-ng-model="firstname" /><br />
姓:<input type="text"data-ng-model="lastname" /><br />
<br />
姓名:{{firstname +" "+ lastname}};
</div>
<br />
</div>
<script src="jQuery/jquery-2.1.4.js"></script>
<script src="bootstrap-3.3.5/dist/js/bootstrap.min.js"></script>
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
<script>
//angularJS模块定义应用
var app = angular.module("myApp", []);
//angularJS控制器控制应用
app.controller("myCtrl",function($scope){
$scope.firstname="w";
$scope.lastname="wh";
})

</script>
</body>
</html>

posted @ 2015-12-12 23:12  melao2006  阅读(104)  评论(0编辑  收藏  举报