[
{id: 1,
name: "test 1",
children: [
{id: 2,
name: "test 1-sub",
children: []}
]
}]
Assuming a json array of something like the above where each element may or may not have children, and it can go up to 9 levels deep.
If I want to know where on the tree I am, and be able to go up or down the tree. I know on the way down I can simple go to the index of the selected child element to see them. How would I go back up the tree?
Basically I'm thinking I'll have two elements on the page. The main array that contains on the data, one element to indicate the current array I'm working with.
codes: any = [];
currentCode: any = {};
To make this easier to read and navigate I am only going to display one level of the tree at a time, so main code, with it's child elements below it.
Do I need to store a map of the path I took to get where I am and walk down from the top each time to get to the point I want to be at?
I hope this isn't too confusing.