0

我想在 Instagram/Pinterest 上创建路由。就我而言 - 在模态窗口中打开全文。从常见问题解答中 ,我找到了以下代码:

    $stateProvider.state("items.add", {
    url: "/add",
    onEnter: ['$stateParams', '$state', '$modal', '$resource', function($stateParams, $state, $modal, $resource) {
        $modal.open({
            templateUrl: "items/add",
            resolve: {
              item: function() { new Item(123).get(); }
            },
            controller: ['$scope', 'item', function($scope, item) {
              $scope.dismiss = function() {
                $scope.$dismiss();
              };

              $scope.save = function() {
                item.update().then(function() {
                  $scope.$close(true);
                });
              };
            }]
        }).result.then(function(result) {
            if (result) {
                return $state.transitionTo("items");
            }
        });
    }]
});

它工作正常,但是当我关闭模式窗口时,之前状态的滚动和数据没有保存。是否有现有的解决方案在关闭模式后保留先前状态的滚动和数据?

4

1 回答 1

0

我在 ui-router-extras 中实现了“粘性状态”。ui-router-extras 是 ui-router 的插件模块。我有一个模态示例/演示,我相信它可以满足您的需求。在此处访问示例:

http://christopherthielen.github.io/ui-router-extras/example/stickymodal/index.html#/people/manager/0/emp/25

然后在这里查看主 ui-router-extras 页面:http: //christopherthielen.github.io/ui-router-extras

于 2014-08-03T01:00:40.270 回答