AngularJS 数据绑定

AngularJS中的数据绑定,同步了AngularJS表达式和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=""data-ng-init="quantity=1;price=9.99">
<p>AngularJS数据绑定:价格计算器</p>
数量:<input type="number"data-ng-model="quantity" />
价格:<input type="number"data-ng-model="price" />
<!--<p><b>总价为:</b><span data-ng-bind="quantity*price"></span></p>-->
<p><b>总价为:</b>{{quantity*price | currency}}</p>
</div>
</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>
</body>
</html>

原文地址:https://www.cnblogs.com/melao2006/p/5055343.html