ng-repeat过滤器在数据重新加载后停止工作

时间:2018-07-18 09:27:09

标签: angularjs

我的购物车角度申请中有一个ng-repeat。我创建了一个自动保存功能,可以将对象保存到本地存储中,如果用户希望继续订购,可以将其重新保存。我遇到的问题是,从对象加载数据后,我的过滤器(首先起作用)停止工作。数据完全相同,唯一不起作用的是过滤器。有办法以某种方式刷新它吗?我没有运气尝试过$ apply()。这是我的功能

if(AppStorage.getAutoSave()){
        if(AppStorage.getAutoSave().data){
        $scope.productcodes = [];
        $scope.productcodes = AppStorage.getAutoSave().data;
        $scope.option = AppStorage.getAutoSave().customer;
        $scope.options = AppStorage.getAutoSave().customer2;
        $scope.customerOrderNumber = AppStorage.getAutoSave().ordernum;

        $scope.review(1);

        var lengthofsaved = $scope.orderdetail.length;

        if(lengthofsaved > 0){

             SweetAlert.swal({
                title: "Unsaved Changes",
                text: "We notice you didn't complete a previous order, would you like to restore this?",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#54addd",
                confirmButtonText: "New Order",
                cancelButtonText: "Restore",
                closeOnConfirm: false,
                closeOnCancel: false },
            function (isConfirm) {
                if (isConfirm) {
                    AppStorage.setAutoSave(null);
                    location.reload();
                    //SweetAlert.swal("Save file cleared!", "You can now begin inputting a new order.", "success");
                } else {
                    SweetAlert.swal("Restored", "You can now continue your order.", "success");
                }
            });

        }
    }
    }

$ scope.productcodes是保存ng-repeat数据的变量,我已经仔细检查过,该数据与从API数据中存储的数据完全相同。

0 个答案:

没有答案
相关问题