{"action":"created","issue":{"url":"https://api.github.com/repos/angular/angular/issues/9697","repository_url":"https://api.github.com/repos/angular/angular","labels_url":"https://api.github.com/repos/angular/angular/issues/9697/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular/issues/9697/comments","events_url":"https://api.github.com/repos/angular/angular/issues/9697/events","html_url":"https://github.com/angular/angular/issues/9697","id":162911574,"number":9697,"title":"Navigating to a route which is mapped to the same component causes unnecessary ngOnDestroy and ngOnInit for this component","user":{"login":"borisvasilenko","id":13434517,"avatar_url":"https://avatars.githubusercontent.com/u/13434517?v=3","gravatar_id":"","url":"https://api.github.com/users/borisvasilenko","html_url":"https://github.com/borisvasilenko","followers_url":"https://api.github.com/users/borisvasilenko/followers","following_url":"https://api.github.com/users/borisvasilenko/following{/other_user}","gists_url":"https://api.github.com/users/borisvasilenko/gists{/gist_id}","starred_url":"https://api.github.com/users/borisvasilenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/borisvasilenko/subscriptions","organizations_url":"https://api.github.com/users/borisvasilenko/orgs","repos_url":"https://api.github.com/users/borisvasilenko/repos","events_url":"https://api.github.com/users/borisvasilenko/events{/privacy}","received_events_url":"https://api.github.com/users/borisvasilenko/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-06-29T12:22:33Z","updated_at":"2016-06-30T20:04:14Z","closed_at":"2016-06-30T20:04:14Z","body":"**I'm submitting a ...**\r\n```\r\n[x] bug report\r\n[ ] feature request\r\n```\r\n\r\n**Current behavior**\r\n\r\nRoute ```/a``` mapped to component ```X```. \r\nRoute ```/b``` is mapped to component ```X``` too.\r\n\r\nNavigating from ```/a``` to ```/b```, and from ```/b``` to ```/a``` will destroy and initialize again component ```X```, although this seems unnecessary. Component ```X``` could have an expensive data fetching in ```ngOnInit```, which should not be done twice.\r\n\r\n**Expected/desired behavior**\r\n\r\nWhen navigating to a new route, which is mapped to the same component, this component should not be destroyed and initialized again.\r\n\r\n**Reproduction of the problem**\r\n\r\nhttp://plnkr.co/edit/Sxu5eMAvsQ4x89fFDWdT?p=preview \r\n\r\n**What is the motivation / use case for changing the behavior?**\r\n\r\nIn our project we have a list of items. The user may choose one, and get the chosen item's ID appended to the URL: ```/listA/itemX```. To achieve that, we navigate to ```/listA/itemX```. Currently we get a full reload of an entire list. (Optional query parameters, like ```/?item=itemX``` do not suite our needs.)\r\n\r\n**Please tell us about your environment:**\r\n\r\n* **Angular version:** 2.0.0-rc.3\r\n* **Router version:** 3.0.0-alpha.7"},"comment":{"url":"https://api.github.com/repos/angular/angular/issues/comments/229772316","html_url":"https://github.com/angular/angular/issues/9697#issuecomment-229772316","issue_url":"https://api.github.com/repos/angular/angular/issues/9697","id":229772316,"user":{"login":"vsavkin","id":35996,"avatar_url":"https://avatars.githubusercontent.com/u/35996?v=3","gravatar_id":"","url":"https://api.github.com/users/vsavkin","html_url":"https://github.com/vsavkin","followers_url":"https://api.github.com/users/vsavkin/followers","following_url":"https://api.github.com/users/vsavkin/following{/other_user}","gists_url":"https://api.github.com/users/vsavkin/gists{/gist_id}","starred_url":"https://api.github.com/users/vsavkin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vsavkin/subscriptions","organizations_url":"https://api.github.com/users/vsavkin/orgs","repos_url":"https://api.github.com/users/vsavkin/repos","events_url":"https://api.github.com/users/vsavkin/events{/privacy}","received_events_url":"https://api.github.com/users/vsavkin/received_events","type":"User","site_admin":false},"created_at":"2016-06-30T20:04:14Z","updated_at":"2016-06-30T20:04:14Z","body":"Reusing components across different routes is problematic for a variety of reasons. So we do not intend implement such a behavior. \r\n\r\nWhat we can do instead is to implement optional positional params (e.g., list/(:id). Meanwhile, you can try to use wildcard routes as a workaround. "}}
{"actor":{"display_login":"vsavkin"}}