2016-04-30 33 views
0

我有一个表100行,如果我进入一个新的排它增加了它,并在表的顶部显示为降序按日期滤波器阶与AngularJs

<table class="table"> 
<tr ng-repeat=" item in itemlist | orderBy:createdat:true"> 
<td>//code goes here</td> 
<td><button ng-click="del(item)" class="fa fa-trash"></button></td> 
</tr> 
</table> 

我有一个所有CRUD操作删除按钮,但问题是,当我删除任何特定的行时,它只删除该特定行,但仍显示该行存在于表中,直到页面被刷新。因此,任何想法..这将是对我很大的帮助.... 下面是代码....只是在JS文件中的代码复制plunker

在HTML

<div ng-app> 
<div ng-controller="FooController"> 
<table> 


    <tr ng-repeat="item in items | orderBy:'num':true"> 
     <td>{{item.num}} :: {{item.desc}}</td> 
     <td><button class="fa fa-trash" ng-click="del($index)"> 
     delete 
     </button></td> 
    </tr> 
    </table> 
</div> 

function FooController($scope) { 
$scope.items = [ 
    {desc: 'a', num: 1}, 
    {desc: 'b', num: 2}, 
    {desc: 'c', num: 3}, 
]; 
$scope.del=function(idx){ 
     $scope.items.splice(idx,1) 
} 
} 
+0

你可以创建plunker吗? –

+0

太宽泛。也许创建一个演示。 – dfsq

+0

因此,您的代码中存在一个错误,并希望找到并修复该错误。我们怎么能没有看到你的代码呢? –

回答

0

HTML部分

<table> 
    <tr ng-repeat="item in items | orderBy:'num':true"> 
    <td>{{item.num}} :: {{item.desc}}</td> 
    <td> 
    <button class="fa fa-trash" ng-click="del(item)"> 
     delete 
    </button></td> 
    </tr> 
    </table> 

JavaScript部分

$scope.items = [ 
{desc: 'a', num: 1}, 
{desc: 'b', num: 2}, 
{desc: 'c', num: 3}, 
]; 
$scope.del=function(idx){ 
    $scope.items.splice($scope.items.indexOf(idx),1) 
} 
+0

谢谢@S。 Divya,它为我工作,删除数组的临时数据。但以同样的方式,我希望它从数据库中删除。那不过是工厂罢了。所以我正在寻找。 – ANK