<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'} } ]