{"action":"created","issue":{"url":"https://api.github.com/repos/NativeScript/nativescript-angular/issues/477","repository_url":"https://api.github.com/repos/NativeScript/nativescript-angular","labels_url":"https://api.github.com/repos/NativeScript/nativescript-angular/issues/477/labels{/name}","comments_url":"https://api.github.com/repos/NativeScript/nativescript-angular/issues/477/comments","events_url":"https://api.github.com/repos/NativeScript/nativescript-angular/issues/477/events","html_url":"https://github.com/NativeScript/nativescript-angular/issues/477","id":179843932,"number":477,"title":"When using nested router-outlet, the back button exits the App","user":{"login":"m-abs","id":1348705,"avatar_url":"https://avatars.githubusercontent.com/u/1348705?v=3","gravatar_id":"","url":"https://api.github.com/users/m-abs","html_url":"https://github.com/m-abs","followers_url":"https://api.github.com/users/m-abs/followers","following_url":"https://api.github.com/users/m-abs/following{/other_user}","gists_url":"https://api.github.com/users/m-abs/gists{/gist_id}","starred_url":"https://api.github.com/users/m-abs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m-abs/subscriptions","organizations_url":"https://api.github.com/users/m-abs/orgs","repos_url":"https://api.github.com/users/m-abs/repos","events_url":"https://api.github.com/users/m-abs/events{/privacy}","received_events_url":"https://api.github.com/users/m-abs/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-09-28T18:02:53Z","updated_at":"2017-01-23T13:27:12Z","closed_at":"2016-10-03T08:40:34Z","body":"I'm trying to add child-routes to my `Angular Native` App, but when I click my android back-button the App just exits.\n\nI've tried to write an example to show what the problem it here: https://github.com/m-abs/angular2-seed-advanced/tree/child-router\nIt's based on Nathan Walker's angular2-seed-advanced as that's what we use in our project.\n\n**What I've done:**\n- I created three Child<N>Components in https://github.com/m-abs/angular2-seed-advanced/tree/child-router/src/client/app/components/home/children\n- I added the child-routes here: https://github.com/m-abs/angular2-seed-advanced/blob/child-router/src/client/app/components/home/home.routes.ts#L13-L18\n- Finally I added the `router-outlet` here: https://github.com/m-abs/angular2-seed-advanced/blob/child-router/src/client/app/components/home/home.component.tns.html#L23\n\n**What happens:**\n- I tap on the Button nsRouterLinks and the components are loaded. Even the `ActionBar` works per Child<N>Component, which were a bit of a surprise.\n- Click on the devices back-button, exits my App right away.\n\n**What I'd expect:**\n- I tap on the Button nsRouterLinks and the components are loaded\n- I click back and the go back to the previous component in history\n\n**More data:**\nI've tried tracing it to try and make heads or tail on it:\n\n``` bash\nJS: ns-router: NSLocationStrategy.path(): /\nJS: Router Event: NavigationStart(id: 1, url: '/')\nJS: Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode.\nJS: Router Event: RoutesRecognized(id: 1, url: '/', urlAfterRedirects: '/home/child1', state: Route(url:'', path:'') { Route(url:'home', path:'home') { Route(url:'child1', path:'child1') }  } )\nJS: ns-router: NSLocationStrategy.path(): /\nJS: ns-router: NSLocationStrategy.replaceState pushing new state: null, title: , url: /home/child1, queryParams: null\nJS: ns-router: PageRouterOutlet.activate() inital page - just load component\nJS: Router Event: NavigationEnd(id: 1, url: '/', urlAfterRedirects: '/home/child1')\nJS: NativeLifecycle: fragment0[0]<Page(1)>.onCreateAnimator(0, enter, undefined): null\nJS: ns-router: nsRouterLink.tapped: /home/child2 usePageRoute: true clearHistory: undefined transition: true\nJS: ns-router: NSLocationStrategy._setNavigationOptions({\"clearHistory\":false,\"animated\":true})\nJS: Router Event: NavigationStart(id: 2, url: '/home/child2')\nJS: Router Event: RoutesRecognized(id: 2, url: '/home/child2', urlAfterRedirects: '/home/child2', state: Route(url:'', path:'') { Route(url:'home', path:'home') { Route(url:'child2', path:'child2') }  } )\nJS: ns-router: NSLocationStrategy.path(): /home/child1\nJS: ns-router: NSLocationStrategy.pushState state: null, title: , url: /home/child2, queryParams: null\nJS: Router Event: NavigationEnd(id: 2, url: '/home/child2', urlAfterRedirects: '/home/child2')\nJS: NativeLifecycle: NativeScriptActivity.onBackPressed;\nJS: TNS Application - Suspended\nJS: NativeLifecycle: NativeScriptActivity.onStop();\nJS: NativeLifecycle: fragment0[0]<Page(1)>.onDestroyView()\nJS: NativeLifecycle: HIDDEN fragment0[0]<Page(1)>; destroyed: true\nJS: NativeLifecycle: fragment0[0]<Page(1)>.onDestroy()\nJS: TNS Application - EXIT\nJS: NativeLifecycle: NativeScriptActivity.onDestroy();\n```\n\nAs you can see NSLocationStrategy.pushState(`/home/child2`) is called for the child-route, but after `onBackPressed` the App just exits.\n"},"comment":{"url":"https://api.github.com/repos/NativeScript/nativescript-angular/issues/comments/274487361","html_url":"https://github.com/NativeScript/nativescript-angular/issues/477#issuecomment-274487361","issue_url":"https://api.github.com/repos/NativeScript/nativescript-angular/issues/477","id":274487361,"user":{"login":"SBD580","id":3942469,"avatar_url":"https://avatars.githubusercontent.com/u/3942469?v=3","gravatar_id":"","url":"https://api.github.com/users/SBD580","html_url":"https://github.com/SBD580","followers_url":"https://api.github.com/users/SBD580/followers","following_url":"https://api.github.com/users/SBD580/following{/other_user}","gists_url":"https://api.github.com/users/SBD580/gists{/gist_id}","starred_url":"https://api.github.com/users/SBD580/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SBD580/subscriptions","organizations_url":"https://api.github.com/users/SBD580/orgs","repos_url":"https://api.github.com/users/SBD580/repos","events_url":"https://api.github.com/users/SBD580/events{/privacy}","received_events_url":"https://api.github.com/users/SBD580/received_events","type":"User","site_admin":false},"created_at":"2017-01-23T13:27:12Z","updated_at":"2017-01-23T13:27:12Z","body":"I see. I though `page-router-outlet` define pages, so going back to previous page should act on the inner one and only then on the outer (when no more routes left)"}}
{"actor":{"display_login":"SBD580"}}