<table id="tb_1" cellspacing="0" cellpadding="2" width="100%" border="1"> <thead> <th ng-repeat="hd in headList">{{hd.name}}</th> </thead> <tbody> <tr ng-repeat="data in tableData"> <td ng-repeat="hd in headList"> <input type="text" ng-model="data[hd.code].value" /> </td> </tr> </tbody> </table>
两个ng-repeat固然得有两个数组对象数组
var head = [ {code:"packageCounts"}, {code:"volume"}, {code:"volumeUnit"}, ] var tableData = [ { packageCounts:{name:"包装件数",value:'1'}, volume:{name:"体积(方)",value:'2'}, volumeUnit:{name:"体积单价",value:'3'} } ]