我有一张桌子,每一行都要使用指令和ng-repeat显示。
不幸的是,这些行是在表上下文之外呈现的。
请在这里运行小提琴:http : //jsfiddle.net/nu1tu9qL/4/
指令:
.directive('myrow', [function () {
return {
restrict: 'E',
replace: true,
scope: {
rowdata: "="
},
template: '<tr><td>{{rowdata.a}}</td><td>{{rowdata.b}}</td></tr>',
};
}]);
Run Code Online (Sandbox Code Playgroud)
HTML:
<table>
<thead>
<th>A</th>
<th>B</th>
</thead>
<tbody>
<myrow ng-repeat="d in data" rowdata="d"></row>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)