ng-options="item.action for item in todos"
ng-options表达式的基本形式, 形如 "<标签> for <项目> in <数组>
<option value="">(chosse one) </option>
ng-options="item.id as item.action for item in todos"
在表单的形式如<所选属性>as <标签> for <变量> in <数组>
ng-options="item.action group by item.place for item in todos"
将对象进行分组
使用无作用域的控制器
<!DOCTYPE html>
<html lang="en" ng-app="iApp">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css">
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap-theme.css">
<script src="bower_components/angular/angular.js"></script>
<script>
angular.module('iApp',[])
.controller('topCtrl',function(){
this.dataValue='Hello,Adam';
this.reverseText=function(){
this.dataValue=this.dataValue.split("").reverse().join("");
}
})
</script>
</head>
<body >
<div class="well" ng-controller="topCtrl as ctrl">
<h4>Top level Controller</h4>
<div class="input-group">
<span class="input-group-btn">
<button class="btn btn-default" ng-click="ctrl.reverseText()">Reverse</button>
</span>
<input type="text" class="form-control" ng-model="ctrl.dataValue">
</div>
</div>
</body>
</html>
当应用无作域的控制器时,表达式的格式化形如:<要应用的控制器> as <变量名>
然后在视图中使用ctrl变量访问数据和行为,类似这样:<input.....ng-model="ctrl.dataValue">