[英]How to replicate a HTML table code when clicked on a button using angular js?
我在HTML中創建了整個表,但是我想實現以下功能:如果單擊文本,則需要在應用程序中復制相同的表(HTML)代碼。
我的HTML :
<th class="bx--table-header bx--table-sort" data-event="sort" ng-click="vm.addTowerTable()">
<a class="text-decoration-none"><i class="fa fa-plus-circle" aria-hidden="true" style="padding-right:10px;"></i>Add Tower</a>
</th>
單擊該文本時,我需要添加一個TOWER作為文本,我需要添加整個表格...如何使用angularjs實現它?
您可以使用ng-repeat
遍歷一個虛擬數組,該數組的長度是所需的表數:
<table ng-repeat="table in vm.tables">
...
<th ng-click="vm.addTowerTable()">
...
</th>
</table>
然后在您的控制器中:
// Right now I am just pushing null since we need something in the
// array. You could push some data about each table.
vm.tables = [null];
vm.addTowerTable = function() {
vm.tables.push(null);
};
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.