[英]Angular dynamic table inline edit
I'm working on dynamic table where I don't know how many columns/rows I have and I'm trying to implement inline edit with inline templates using ng-include.我正在处理动态表,我不知道我有多少列/行,我正在尝试使用 ng-include 使用内联模板实现内联编辑。
First problem:第一个问题:
How to use ng-include on < tr > level and include scripts inside < td >, is it even possible?如何在 <tr> 级别使用 ng-include 并在 <td> 内包含脚本,甚至可能吗? I could call ng-inlcude on the < td > level but I guess that would be huge overhead...我可以在 < td > 级别调用 ng-inlcude 但我想这将是巨大的开销......
Second problem:第二个问题:
How to use the same ng-include to include edit_btn/display_btn templates outside of ng-repeat as the last cells?如何使用相同的 ng-include 将 edit_btn/display_btn 模板包含在 ng-repeat 之外作为最后一个单元格?
<tr ng-repeat="row in model.array" ng-include="model.isEditMode(row)">
<td ng-repeat="(k, v) in row" ng-show="model.header[$index].display == true" class="text-center" >
<script type="text/ng-template" id="edit">
<div ng-if="model.header[$index].isDisabled == true">
<div ng-if="model.header[$index].type == 'datetime'">
<input type="text" class="form-control" ng-model="model.dateTime"/>
</div>
<div ng-if="model.header[$index].type == 'string'">
<input type="text" class="form-control" ng-model="v"/>
</div>
</div>
<div ng-if="model.header[$index].isDisabled == false">
<div ng-if="model.header[$index].type == 'datetime'">
<input type="text" class="form-control" ng-model="model.dateTime" />
</div>
<div ng-if="model.header[$index].type == 'string'">
<input type="text" class="form-control" ng-model="v" />
</div>
</div>
</script>
<script type="text/ng-template" id="display">
<div ng-if="model.header[$index].isDisabled == true">
<div ng-if="model.header[$index].type == 'datetime'">
{{model.dateTime}}
</div>
<div ng-if="model.header[$index].type == 'string'">
{{v}}
</div>
</div>
<div ng-if="model.header[$index].isDisabled == false">
<div ng-if="model.header[$index].type == 'datetime'">
{{model.dateTime}}
</div>
<div ng-if="model.header[$index].type == 'string'">
{{v}}
</div>
</div>
</script>
</td>
<script type="text/ng-template" id="edit_btn">
<td>
<button type="button" class="btn btn-primary" ng-click="model.save(entry)">save</button>
</td>
</script>
<script type="text/ng-template" id="display_btn">
<td>
<button type="button" class="btn btn-primary" ng-click="model.edit(entry)">edit</button>
</td>
</script>
</tr>
You can use Angular-xeditable, which can be found in the following link: https://vitalets.github.io/angular-xeditable/ .您可以使用 Angular-xeditable,它可以在以下链接中找到: https ://vitalets.github.io/angular-xeditable/。 You can find the implementation you need on there.你可以在那里找到你需要的实现。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.