{"action":"created","issue":{"url":"https://api.github.com/repos/ionic-team/ionic/issues/16736","repository_url":"https://api.github.com/repos/ionic-team/ionic","labels_url":"https://api.github.com/repos/ionic-team/ionic/issues/16736/labels{/name}","comments_url":"https://api.github.com/repos/ionic-team/ionic/issues/16736/comments","events_url":"https://api.github.com/repos/ionic-team/ionic/issues/16736/events","html_url":"https://github.com/ionic-team/ionic/issues/16736","id":391026124,"node_id":"MDU6SXNzdWUzOTEwMjYxMjQ=","number":16736,"title":"[4.0.0.beta-17] ActivatedRoute.queryParams break after navigation","user":{"login":"h4rm","id":569550,"node_id":"MDQ6VXNlcjU2OTU1MA==","avatar_url":"https://avatars2.githubusercontent.com/u/569550?v=4","gravatar_id":"","url":"https://api.github.com/users/h4rm","html_url":"https://github.com/h4rm","followers_url":"https://api.github.com/users/h4rm/followers","following_url":"https://api.github.com/users/h4rm/following{/other_user}","gists_url":"https://api.github.com/users/h4rm/gists{/gist_id}","starred_url":"https://api.github.com/users/h4rm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/h4rm/subscriptions","organizations_url":"https://api.github.com/users/h4rm/orgs","repos_url":"https://api.github.com/users/h4rm/repos","events_url":"https://api.github.com/users/h4rm/events{/privacy}","received_events_url":"https://api.github.com/users/h4rm/received_events","type":"User","site_admin":false},"labels":[{"id":999106337,"node_id":"MDU6TGFiZWw5OTkxMDYzMzc=","url":"https://api.github.com/repos/ionic-team/ionic/labels/package:%20angular","name":"package: angular","color":"dc0030","default":false},{"id":1143756678,"node_id":"MDU6TGFiZWwxMTQzNzU2Njc4","url":"https://api.github.com/repos/ionic-team/ionic/labels/type:%20bug","name":"type: bug","color":"cc2302","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":11,"created_at":"2018-12-14T09:13:59Z","updated_at":"2018-12-18T23:19:59Z","closed_at":null,"author_association":"NONE","body":"# Bug Report\r\n\r\n**Ionic version:**\r\n4.0.0.beta-17 and 4.0.0.beta-18\r\n\r\n**Current behavior:**\r\nSubscriptions on ActivatedRoute.queryParams do not fire after navigating away from and returning to that page. This is particullary problematic for base pages of tabs that are cached. The problem does not occur on sub-pages because they are re-initialized i.e. onInit fires again and again (e.g. on speaker-detail in ionic-conference app).\r\n\r\n**Expected behavior:**\r\nNavigation should not interfere with the queryParams subscription.\r\n\r\n**Steps to reproduce:**\r\n1. Clone ionic-conference-app\r\n2. Add code below\r\n3. Test with \"Test\" button on speakers list. Observe console log of queryParams. Navigate to speaker detail and back. Try \"Test\" button again and observe no console output.\r\n4. Test same with Test button speaker detail page. Navigate from base to detail and back and to detail again - logs are fired.\r\n\r\n**Related code:**\r\n\r\n`speaker-list.html`\r\n```...\r\n<ion-content class=\"outer-content\">\r\n   <!-- TEST BUTTON -->\r\n  <ion-button (click)=\"test()\">Test</ion-button>\r\n\r\n  <ion-list>\r\n...\r\n```\r\n\r\nin `speaker-list.ts` modify\r\n```\r\n...\r\nexport class SpeakerListPage implements OnInit {\r\n  speakers: any[] = [];\r\n\r\n  constructor(\r\n    public actionSheetCtrl: ActionSheetController,\r\n    public confData: ConferenceData,\r\n    public inAppBrowser: InAppBrowser,\r\n    private route: ActivatedRoute,\r\n    private router: Router\r\n  ) {}\r\n\r\n  ngOnInit() {\r\n    console.log('Init');\r\n    this.route.queryParams.subscribe(test => console.log(test));\r\n  }\r\n\r\n  test() {\r\n    this.router.navigate(['./'], { queryParams: { test: Math.random() }, relativeTo: this.route });\r\n  }\r\n...\r\n```\r\n\r\n**Ionic info:** \r\n```\r\nIonic:\r\n\r\n   ionic (Ionic CLI)             : 4.5.0 (C:\\Users\\Ferdinand\\AppData\\Roaming\\npm\\node_modules\\ionic)\r\n   Ionic Framework               : @ionic/angular 4.0.0-beta.17\r\n   @angular-devkit/build-angular : 0.10.7\r\n   @angular-devkit/schematics    : 7.1.3\r\n   @angular/cli                  : 7.1.3\r\n   @ionic/angular-toolkit        : 1.2.0\r\n\r\nCordova:\r\n\r\n   cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)\r\n   Cordova Platforms     : android 7.1.4\r\n   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.2.5, (and 8 other plugins)\r\n\r\nSystem:\r\n\r\n   NodeJS : v10.11.0 (C:\\Program Files\\nodejs\\node.exe)\r\n   npm    : 6.4.1\r\n   OS     : Windows 10\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/ionic-team/ionic/issues/comments/448408927","html_url":"https://github.com/ionic-team/ionic/issues/16736#issuecomment-448408927","issue_url":"https://api.github.com/repos/ionic-team/ionic/issues/16736","id":448408927,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0ODQwODkyNw==","user":{"login":"daem0ndev","id":2738707,"node_id":"MDQ6VXNlcjI3Mzg3MDc=","avatar_url":"https://avatars1.githubusercontent.com/u/2738707?v=4","gravatar_id":"","url":"https://api.github.com/users/daem0ndev","html_url":"https://github.com/daem0ndev","followers_url":"https://api.github.com/users/daem0ndev/followers","following_url":"https://api.github.com/users/daem0ndev/following{/other_user}","gists_url":"https://api.github.com/users/daem0ndev/gists{/gist_id}","starred_url":"https://api.github.com/users/daem0ndev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daem0ndev/subscriptions","organizations_url":"https://api.github.com/users/daem0ndev/orgs","repos_url":"https://api.github.com/users/daem0ndev/repos","events_url":"https://api.github.com/users/daem0ndev/events{/privacy}","received_events_url":"https://api.github.com/users/daem0ndev/received_events","type":"User","site_admin":false},"created_at":"2018-12-18T23:19:59Z","updated_at":"2018-12-18T23:19:59Z","author_association":"NONE","body":"I can confirm this issue as this was quite a blocker for us, the problem is that the OutletInjector class inside ion-router-outlet only provides the correct ActivatedRoute during initial component initialization, but this is not the correct ActivatedRoute when re-activating a component thats already in the ion-router-outlet stack. The fact of the matter is, there is no easy way to correct this issue from Ionic's side because you cant change the injected activated route after the fact. In other words, the activated route thats injected on a component is only correct if the component is being created by the factory, NOT if we are reactivating a component thats already created, and navigating BACK to that component is actually a whole new navigation and therefor new ActivatedRoute object.\r\n\r\nI implemented a very crude workaround to this issue because we have a tight deadline to release our app. The main gist of the solution is that I created a service that always maintains the current activated route as well as the component that is activated and exposes this via an observable, and then on my page components I use this service to get the latest (and correct) instance of ActivatedRoute as it changes over time (i.e. when navigating BACK to a component on the stack) and then you can correctly switchMap over to the queryParamMap on that new ActivatedRoute."}}
{"actor":{"display_login":"daem0ndev"}}