将 table 行从一个 table 移动到另一个 - AngularJS

Move table row from one table to another - AngularJS

我有一个关于 ng-repeat 的问题,以及如何将数据从一个 table 移动到另一个。基本上我有一个 table 即 "master" 并显示来自 API 请求的所有数据,在我将它填充到 table 之后我在每一行上都有一个按钮,就像"favorite-this-row"。用户单击 "favorite-this-row" 后,我希望它将该行移动到另一个名为 "favorite-table" 的 table 并在此处显示数据。

这是我的 "Master"-table:(我不会粘贴整个 table 只是需要的部分)

<md-card flex="45" flex-sm="100" flex-md="100" flex-xs="100" 
    ng-show="(account|filter:searchName).length > 0"
    ng-repeat="account in containers | groupBy: 'accountId'  | toArray | filter:searchName track by $index ">

        ... Bunch of HTML code down......

    **//Favorite button**

<md-button ng-init="item.isfavorite = false;"
       ng-class="{yellow : item.isfavorite}"
       ng-click="item.isfavorite =!item.isfavorite; AddFavorite(item.isfavorite,container.containerId)"
       class="md-icon-button md-accent md-warn" aria-label="Favorite">      
<ng-md-icon icon="favorite" ng-init="item.isfavorite = false;"></ng-md-icon>
</md-button>

<p ng-if="item.isfavorite">Remove from favorites - {{item.isfavorite}} </p>
<p ng-if="!item.isfavorite">Add to favorite</p>

现在这是我的 "Favorite"-table:

<table>
   <tr ng-repeat="x in containers" ng-show="item.isfavorite">
         <td>s{{ x.containerId }}</td>
         <td>s{{ x.accountId }}</td>
    </tr>
</table>

当我单击按钮 <md-button ng-init="item.isfavorite = false;" ....> 时,我希望它切片并移动到我最喜欢的 table,它只是重复 containerIdaccountId。如您所见,我添加了 ng-show="item.isfavorite" 但没有 work/show.

AddFavorite(item.isfavorite,container.containerId)" 只是控制器中的一个 console.log

希望有人能帮助我,谢谢!

正如@avius 所说,它应该是 account 而不是 favirote 中的项目 table 它应该是 x 而不是 item 类似

<md-button class="md-raised" ng-click="account.isfavorite =!account.isfavorite">Button</md-button>

<p ng-if="account.isfavorite">Remove from favorites - {{account.isfavorite}} </p>
<p ng-if="!account.isfavorite">Add to favorite</p>



 <tr ng-repeat="x in containers" ng-show="x.isfavorite">

Check this plunker