Skip to content

RFC: Detached state #1133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sarunas opened this issue Jun 6, 2014 · 5 comments
Closed

RFC: Detached state #1133

sarunas opened this issue Jun 6, 2014 · 5 comments

Comments

@sarunas
Copy link

sarunas commented Jun 6, 2014

Hi,

just wanted to discuss how to solve one use case with ui-router.

Problem:

  • Open modal dialog (base of solution as in FAQ)
  • Modal background should be last state
  • Then going to modal state (url) directly it should have default state in background

To solve this issue, added few things in ui-router core:

  • detached option
  • needState option

Usage:

    $stateProvider.state('modal', {
      url: '/modal',
      detached: true,
      needsState: true,
      needsStateDefault: 'defaultStateName',
      onEnter: ['$state', '$modal', function ($state, $modal) {
        var modal = $state.modal = $modal.open({
          template: '<div>Modal with state in background</div>'
        });

        modal.result.then(null, function () {
          $state.modal = null;
          return $state.transitionTo($state.$detached || 'defaultStateName', $state.$detachedStateParams);
        });
      }],
      onExit: ['$state', function ($state) {
        if ($state.modal) {
          $state.modal.close();
        }
      }]
    });

Changes (no tests yet):
https://github.com/sarunas/ui-router/compare/detached-states-pr

What stuff o I need to make in order these features to be part of ui-router?

@nikaspran
Copy link
Contributor

👍

@donatas
Copy link

donatas commented Jun 9, 2014

can't wait :)

@jamesjwarren
Copy link

Sounds like a great idea, there's much discussion around the repo RE the problem you describe... #953

@mlegenhausen
Copy link

+1

@eddiemonge
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants