我正在尝试使用AngularJS中的指令和tansclude组合一个可重用但自定义的表类型控件,而且我遇到了一个无法使用{{syntax}}自定义进入表列的内容的墙.
我尝试了很多不同的变化,但一直无法使它工作.我会包含代码,但我不认为我在正确的轨道上?
我想要实现的目标:
数据:
mymodel.items = [{ number: 1, name: 'John'}, {number: 2, name: 'Bob'}]
Run Code Online (Sandbox Code Playgroud)
HTML:
<grid items="mymodel.items">
<column title="#">#{{item.number}}</column>
<column title="Name"><b>Hello {{item.name}}</b></column>
</grid>
Run Code Online (Sandbox Code Playgroud)
模板:
<table>
<thead>
<th ng-repeat="column in columns">{{column.title}}</th>
</thead>
<tbody>
<tr ng-repeat="item in items">
<td ng-repeat="column in columns">{{columnValue(item, column.content)}}</th>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
预期产量:
<table>
<thead>
<th>#</th>
<th>Name</th>
</thead>
<tbody>
<tr>
<td>#1</td>
<td>Hello John</td>
</tr>
<tr>
<td>#2</td>
<td>Hello Bob</td>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
我似乎无法弄清楚如何在"网格"中转换内容,以便可以进行插值.
angularjs angularjs-directive angularjs-scope angularjs-ng-repeat