Restangular删除之后,从列表中删除()不工作 [英] Restangular delete from list after remove() not working

查看:166
本文介绍了Restangular删除之后,从列表中删除()不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在试图与Restangular工作,但也有一些问题,我跑进去。我不知道如果我似乎其Restangular的实施,还是我缺乏了解,但不能删除Restangular对象从返回的GetList任何东西。

i've been trying to work with Restangular, but there are some issues i'm running into. i'm not sure if its the implementation of Restangular, or my lack of understanding, but i can't seem to delete anything from a returned getList on the Restangular object.

我看这篇文章,试图实现非常类似于这样:

I was looking at this post and trying to implement something very similar to this:

<一个href=\"http://stackoverflow.com/questions/22095128/angularjs-restangular-crud-simplify-dry-controllers\">AngularJS (Restangular CRUD,简化/ DRY控制器?)

但无论我做什么,我不能删除或从列表中删除的项目。添加或推的罚款。但不能删除。我回去,并做了完全一样的文档说。这里是我的榜样删除功能:

But no matter what i do, i can't delete or remove items from the list. adding or pushing is fine. but not deleting. I went back and did it exactly like the docs said. here is my example delete function:

$scope.deletePost = function(item){
item.remove().then(function(results){
$scope.posts = _.without($scope.posts, item);
});

};

我试过刚才的一切,所以我希望这里有人可以阐明实施Restangular删除一些轻。确实如此,事实上,从数据库中删除的项目,howver,我遇到,然后更新在客户端列表中没有做一个完整的GetList()调用的问题。我已经试过_.without和拼接为好。似乎没有任何工作。

I've tried just about everything, so i'm hoping that somebody here can shed some light on implementing Restangular delete. it Does, in fact, remove the item from the database, howver, the problem i'm having is then updating the list on the client side without doing a full getList() call. i've tried the _.without and splice as well. nothing seems to work.

感谢。

推荐答案

我有这个问题了。

这个工作对我的code:

this worked on my code:

$scope.deletePost = function(item){
    item.remove().then(function(results){
        $scope.posts.$object.splice($scope.posts.$object.indexOf(item),1);
    });
}

这篇关于Restangular删除之后,从列表中删除()不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆