<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
input{
width: 50px;
}
</style>
</head>
<body ng-app="myApp">
<div ng-controller="z1" ng-init="age=18">
<input type="text" ng-model="username" /><br>
<p>{{age}}</p>
</div>
<div ng-controller="z2">
A:<input type="number" ng-model="one"/>
B:<input type="text" ng-model="two"/>
自动积:<span ng-bind="one*two"></span><br>
<button ng-click="jisuan()">计算</button>手动积:{{sdj}}
<br><br><br>
<table>
<thead>
<th>序号</th>
<th>是否为最后一行</th>
<th>姓名</th>
<th>年龄</th>
</thead>
<tbody ng-repeat="uu in user">
<tr>
<td>{{$index+1}}</td>
<td>{{$odd}}</td>
<td ng-bind='uu.username'></td>
<td>{{uu.age}}</td>
</tr>
</tbody>
</table>
<br><br><br>
<button ng-click="qh()">切换效果</button>
<p ng-show="yes">我爱angularJS</p>
<p ng-hide="yes">angularJS爱我</p>
</div>
<script src="../js/angular-1.2.9.js" type="text/javascript" charset="utf-8"></script>
<script type='text/javascript'>
angular.module('myApp',[])
.controller('z1',['$scope', function(a){
a.username = '张三';
a.age = 19;
}])
.controller('z2',['$scope', function(a){
a.one = 5;
a.two = 10;
a.sdj = 50;
a.jisuan = function(){
a.sdj = a.one * a.two;
}
a.user = [
{username:'刘博',age:23},
{username:'韩方兴',age:21},
{username:'陈美琪',age:18},
{username:'陈美琪',age:18}
];
a.yes = true;
a.qh = function(){
a.yes = !a.yes;
}
}])
</script>
</body>
</html>