<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
</head>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
名字: <input ng-model="name">
<h1>{{name}}</h1>
<table >
<tr>
<th ng-repeat="y in attrlist">
{{y.name}}
</th>
</tr>
</table>
<table ng-repeat="y in attrlist">
<tr ng-repeat="x in y.attr_values">
<td>
{{y.name}}{{x.v_name}}
</td>
<td>
价格:<input name="{{x.attrid}}-price">
</td>
</tr>
</table>
</div>
<script>
var app = angular.module(‘myApp‘, []);
app.controller(‘myCtrl‘, function($scope) {
$scope.name = "John Doe";
$scope.attrlist=[{attrid:1,name:‘颜色‘,attr_values:[{v_id:1,v_name:‘白色‘},{v_id:2,v_name:‘黑色‘}]},{attrid:2,name:‘内存容量‘,attr_values:[{v_id:3,v_name:‘16G‘},{v_id:4,v_name:‘32G‘}]},{attrid:3,name:‘网络类型‘,attr_values:[{v_id:5,v_name:‘移动‘},{v_id:6,v_name:‘联通‘}]}];
});
</script>
<p>使用 ng-model 指令来绑定输入域的值到控制器的属性。</p>
</body>
</html>
原文:http://www.cnblogs.com/westfruit/p/5210807.html