-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Router resolved data does not persist in ActivatedRoute data after navigation #12306
Comments
@michaelchiche You can access this data through parent.
with this:
You will get it all. The real question is why when we first resolved data the data is flatted but when we go upward of url tree we must access data exactly at the node which defined it. |
@olegdunkan What you say is true, but I am not looking for a hack. It works for simple routes, but what happens when I have 3 or more different nesting levels of children? From what I understand, I am supposed to be able to access the data resolved after navigation inside the data property, which is not the case. |
@michaelchiche it is not hack, it is the way you can access data from parents, you can write simply function that go upward to any level. 'Parent' is a public property of route and snapshot. I didn't see any reasons do not use it. More then this it is the right way to get data from parents. How do you think to implement all data at all levels? Let say we have n levels and all levels resolves to data, in first level we have one property of data, next level adds one more, and finally we have n(n+1)/2 properties and n^2 complexity. Of course we can use prototyping but this is the same like parent property.
|
@olegdunkan: that's not the point... I am not asking how to do it... I am filing a bug report because the documentation says that it is suppose to work without additional work. |
@michaelchiche could you please give me the link where it is described in documentation? |
@olegdunkan: Are you being serious? if you don't know what you are talking about, please do not pollute the issue. thanks... And for your information, it is said here: https://angular.io/docs/ts/latest/guide/router.html#!#activated-route
You can also check my plunker ;) |
The same question was asked at the vsavkin.com blog he answered that we have to use parent property. It is what I want to say, how it works
I repeat the real question why you get data at first. It wouldn't be that way. Documentation says common words you can't conclude exactly that data gathered from levels above. |
+1. that's the real issue |
@DzmitryShylovich @olegdunkan No. In his gist, he shows how to share resolved data between child components... Look at the plunker please |
http://plnkr.co/edit/NgDlGWjrMQC8pMVzSVkA?p=preview this is the correct plunker and expected behavior. Did he write anything about data availability in his blog? No. |
@michaelchiche he (Victor) shows us how to share, not how to access data. |
so can you explain why I can access the data defined in the data property of the parent without calling |
it's the actual bug. and u have access only on initial navigation. or may be it's a feature. Need feedback from Victor |
To my understanding, its the other way around. |
@michaelchiche I have tried to explain you why data merge is not good idea and it seems to me that it is more likely bug then feature (n^2 to store all data) although for first navigation it is more likely feature. If it is a feature then every navigation along the path have to be accompanied with collection of data. Let say we have a/b/c/d/e Let first we navigate to a/b/c/d/e then at 'e' we will have all data (a/b/c/d, e) and it will cost nothing to get it because we go along the 'a', b', .. 'e' and we can preserve resolved data. But what if next navigation will be to a/b/c (upward) (we resolved a,b and c already we only need access to it)? Then to get {a,b,c} we have to keep it in 'c' node in merged form or collect it from a to c and get it to user. It is not necessary in many cases to have data from levels above at every level. |
@michaelchiche I will try to check it. By the way, if we have the same name of data properties at different levels then how conflicts will be resolved?
It is difficult to maintain |
@michaelchiche |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
I'm submitting a ... (check one with "x")
Current behavior
The router resolved properties are not persisted inside the ActivatedRoute data unlike the data properties.
Expected behavior
The router resolved properties should be persisted inside the ActivatedRoute data like the data properties.
Minimal reproduction of the problem with instructions
http://plnkr.co/edit/twhzHaywqxVDPhD2R1NT?p=preview
What is the motivation / use case for changing the behavior?
Some motivations are:
Please tell us about your environment:
Angular version: 2.1.0
Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
Language: [all | TypeScript X.X | ES6/7 | ES5]
Node (for AoT issues):
node --version
= v6.8.0The text was updated successfully, but these errors were encountered: