I'm trying to learn Angular and in doing so I have created a small file explorer like application. It has two components layed out like this:
------------------------------------
- - -
- [DirectoryList] - [Details] -
- - -
- - -
------------------------------------
- The DirectoryList component displays a list of files and folders within the currently selected directory. Clicking a file selects it and shows details in the Details component (shared service). Doubleclicking a folder opens it and updates DirectoryList to display its content instead.
- The Details component displays information about the currently selected file.
What I'd like to do is have the DirectoryList component change its currently open folder and selected item based on the path or query-string of the url, but I can't figure out how to do this. I basically just want the DirectoryList component to react whenever the path changes and update its view accordingly like so:
url: http://myapp/root/sub1/sub2 <- Opens the folder sub2 in DirectoryList
url: http://myapp/root/sub1/sub2/file.txt <- Opens the folder sub2 and the details for file.txt
I've read up on the routing mechanism in Angular, but I can't find a way to do this (which in my mind should be simple). Every configuration seem to indicate that I HAVE TO combine a route with a component and have that component displayed in a <routing-link>
container. However all my routes use the exact same components so there is no need for such a container. The only thing I want is for DirectoryList to get notified whenever the path changes and update itself and the Details component (shared service) accordingly.
Am I misunderstanding something fundamental here? Can this be achieved in a simple way?