摘要:angular boby init
<!DOCTYPE html>
<html ng-app="CalApp">
<head>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body ng-init="PName='T-shirt';Price=100;Qty=10">
<form class="span5 form-inline" style="margin-top:20px;" ng-controller="CalCtrl">
product Name:<input type="text" ng-model="PName"><br>
product Price:<input type="number" ng-model="Price" ng-init="1"><br>
product quantity:<input type="number" ng-model="Qty" ng-init="1"><br>
<br>
Purchase Product: {{PName||'N/A'}}
<br>
Total price: {{Price* Qty||0 | currency:'NT$ '}}
<br>
Total price: NT$ {{Price* Qty||0 | number:0}}
</form>
<br><br><br>
<hr>
<div class="well span6" ng-controller="PersonCtrl">
<label>Name:</label>
<input type="text" ng-model="name" placeholder="Enter a name here">
<br>
<label>Age:</label>
<input type="text" ng-model="age" placeholder="Enter a number here">
<hr>
<h1>{{ name }}</h1>
<h2>{{ age }}</h2>
</div>
</body>
</html>