0

I want to create routing like on the Instagram/Pinterest. In my case - open full article in the modal window. From FAQ I find this code:

    $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");
            }
        });
    }]
});

It works ok, but when I'm closing modal window, the scroll and data of the previous state are not saved. Whether there is an existing solution that retains scroll and data from the previous state after closing modal?

Yaroslav Osetrov
  • 894
  • 1
  • 10
  • 13
  • If `ui-router` works like the regular ngRoute, you need to hack around to avoid your app to refresh. At least that s the issue I see here. I'll post some references in a minute. – Alex C Aug 01 '14 at 17:13
  • This might interest you: http://stackoverflow.com/questions/22940106/path-change-without-reloading-the-route-allow-back-button-to-reload-the-route – Alex C Aug 01 '14 at 17:13

1 Answers1

0

I've implemented "Sticky States" in ui-router-extras. Ui-router-extras is an addon module for ui-router. I have a modal example/demo which I believe does what you want to do. Visit the example here:

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

Then check out the main ui-router-extras page here: http://christopherthielen.github.io/ui-router-extras

Chris T
  • 8,186
  • 2
  • 29
  • 39