Angularjs 数据双向绑定

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="X-UA-Compatible"content="edge" />
<meta name="viewport"content="width=device-width,initial-scale=1" />
<title></title>
<meta charset="utf-8" />
<link rel="stylesheet"href="bootstrap/css/bootstrap.min.css" />
<style>

</style>
</head>
<body>
<div class="container"style="padding:50px">
<div data-ng-app="myApp"data-ng-controller="myCtrl">
<p>姓名:<input type="text"data-ng-model="name" /></p>
<p>性别:<input type="radio"data-ng-model="sex" value="男" name="sex"/>男<input type="radio"data-ng-model="sex" value="女" name="sex"/>女</p>
<p>兴趣:<input type="checkbox"value="跑步" data-ng-model="interest1"/>跑步<input type="checkbox"value="羽毛球" data-ng-model="interest2"/>羽毛球<input type="checkbox"value="编程" data-ng-model="interest3"/>编程</p>
<br /><hr />
<fieldset>
<legend>{{name}}:个人信息如下:</legend>
<p>性别:{{sex}}</p>
<p>兴趣:{{interest1}}{{interest2}}{{interest3}}</p>
</fieldset>

</div>


</div>

<script src="jQuery/jquery-2.2.0.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
<script>
angular.module("myApp", []).controller("myCtrl", function ($scope) {

})
</script>
</body>
</html>

posted @ 2016-01-09 17:53  melao2006  阅读(156)  评论(0编辑  收藏  举报