Javascript 使用remove()后重新启动Angular/angularjs对象不更新

Javascript 使用remove()后重新启动Angular/angularjs对象不更新,javascript,angularjs,restangular,Javascript,Angularjs,Restangular,我在我的AngularJS中使用Restangular。我有一个显示所有消息的索引视图。我可以编辑这些消息并将其添加到列表中而不会出现问题。当我试图通过元素使用remove()时,显示所有消息的索引页不会更新。我必须刷新页面。添加或编辑后,我不需要刷新页面 很抱歉没有包括plunker,但我不确定如何获得一个工作示例,因为我的API是本地的 我通过resolve注入messages对象: $routeProvider.when('/', { templateUrl: 'messages-

我在我的AngularJS中使用Restangular。我有一个显示所有消息的索引视图。我可以编辑这些消息并将其添加到列表中而不会出现问题。当我试图通过元素使用
remove()
时,显示所有消息的索引页不会更新。我必须刷新页面。添加或编辑后,我不需要刷新页面

很抱歉没有包括plunker,但我不确定如何获得一个工作示例,因为我的API是本地的

我通过resolve注入messages对象:

$routeProvider.when('/', {
    templateUrl: 'messages-index.html',
    controller: 'MessagesController',
    resolve: {
        messages: function(Restangular) {
            return Restangular.all('messages').getList();
        }
    }
});
并使用
ng repeat
在索引视图中显示消息:

<li ng-repeat="message in messages | filter:query | filter:typeQuery class="messages__item">
    <p>
        <a href="#/messages/{{ message.id }}/">{{ message.message }}</a>
        <a class="round secondary label">{{ message.type }}</a>
    </p>
</li>
最后,我的
MessagesEditController
如下所示:

.controller('MessagesEditController', ['message', '$scope', '$location', 'Restangular', function(message, $scope, $location, Restangular) {
        var original = message;
        $scope.message = Restangular.copy(original);

        $scope.editMessage = function() {
            $scope.message.put().then(function(){
                $location.path('/');
            }, function(response) {
                $scope.formErrors = response.data.error.params;
            });
        };

        $scope.deleteMessage = function() {
            original.remove().then(function() {
                $location.path("/");
            });
        };
}])
有人知道为什么删除后我的邮件对象在索引视图中没有更新吗


干杯

由于某种原因,restanglar让用户在执行删除操作后更新其$scope。根据用例的不同,它可能是有用的

original.remove().then(function() {
    $scope.messages = _.without($scope.messages, original);
});
original.remove().then(function() {
    $scope.messages = _.without($scope.messages, original);
});