angular-ui / ui-router

The de-facto solution to flexible routing with nested views in AngularJS
http://ui-router.github.io/
MIT License
13.56k stars 3.01k forks source link

Can't change states after destroying secondary angularjs app #3617

Closed ProdigySim closed 4 years ago

ProdigySim commented 6 years ago

This is a (check one box):

My version of UI-Router is: 1.0.12 My version of AngularJs is: 1.6.7, 1.5.8

Bug Report

Current Behavior:

I have a project that leverages two angular applications (created with angular.bootstrap()) on the same page. They both use ui-router and work fine while they are alive (state transitions and all).

However, if I destroy one angular app ($rootScope.$destroy()), the routing on the other app stops working.

Expected Behavior:

The routing should still work properly on the other angular app, even after one dies.

Note: This was working fine on ui-router 0.4.2

Link to Plunker or stackblitz that reproduces the issue:

I built it on jsbin because I am a pleb: https://jsbin.com/sufamusice/1/edit?html,js,output

Mostly minimal repro:

  1. A first angular app is running on the page, with multiple states ("Home" and "State 2")
  2. Note that navigation between these works fine
  3. Click "Open Sub App" to bootstrap the 2nd angular application
  4. Note that navigation between states on both applications work fine.
  5. Click on "Close Sub App" to tear down the 2nd angular application
  6. Note that navigation no longer works on the main application
ProdigySim commented 6 years ago

From services.ts it looks like maybe $q and $injector are shared across multiple ui-router instances, and so when $rootScope dies on my new app, $q at the very least stops working.

Edit: I can confirm that replacing the services.$q with a reference to the older app's $q makes the page work again.

ProdigySim commented 6 years ago

Just tried to update to ui-router 1.0 again and I'm still hitting this issue.

The line overriding the services has moved.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

This does not mean that the issue is invalid. Valid issues may be reopened.

Thank you for your contributions.