Angularjs ng网格和后退按钮:记住网格选择和数据

Angularjs ng网格和后退按钮:记住网格选择和数据,angularjs,ng-grid,Angularjs,Ng Grid,我有一个ng网格视图,如下所示: <div class="ng-grid-style" ng-grid="customersGrid"></div> 我还使用以下两种方法绑定网格: $scope.customersGrid = { data: 'customers', selectedCustomers: $scope.selectedCustomers }; 我还从控制器实例开头的URL获取客户: $scope.fetchCustomers()

我有一个ng网格视图,如下所示:

 <div class="ng-grid-style" ng-grid="customersGrid"></div>
我还使用以下两种方法绑定网格:

$scope.customersGrid = { 
    data: 'customers',
    selectedCustomers: $scope.selectedCustomers
};
我还从控制器实例开头的URL获取客户:

$scope.fetchCustomers() = {

    // with $http I bring customers...
    // (...)

    $scope.customers = response.customers
};

$scope.fetchCustomers();
在视图中,我有指向同一应用程序的其他路由的链接。这些管线关联由其他控制器控制的其他视图

我的问题是,如果我从包含ng网格的视图导航到另一个视图,然后使用后退按钮,我将丢失
$scope.customers
$scope.selectedCustomers
的状态

此应用程序是SPA,因此我应该能够在应用程序的整个生命周期中将这两个应用程序保存在内存中(或其他地方),而不是将它们放在
$scope

最推荐的存储这两者的方法是什么?我已经读到我可以使用localStorage、SessionTarget、服务等。另外,我不确定如果不使用作用域,绑定是如何工作的。我可以将不在范围内的内容传递给网格的数据吗?例如:

$scope.customersGrid = { 
    data: localStorage.customers,                            // possible?
    selectedCustomers: localStorage.selectedCustomers        // possible?
};

LocalStorage:非常易于使用,如果您使用的是iOS应用程序,例如,您可以使用HTML-5存储并将数据存储到文件系统中,例如“*.json”文件,然后读取该数据。此外,您还可以存储cookies$。cookie:但如果您不想保存cookies,最简单的方法是使用localStorage,但这取决于您的应用程序愿望更新:还有一个localStorage插件:
$scope.customersGrid = { 
    data: localStorage.customers,                            // possible?
    selectedCustomers: localStorage.selectedCustomers        // possible?
};