I am trying to create a file viewer and I want to nest the subdirectories. I am using ui-router and I want each subdirectory to have its own URL and state.
Say I have the following structure:
Root
|__Folder
|__Folder
|__SubFolder
|__SubSubFolder
I want my routes to be:
files/:folderID/:SubFolderID/:SubSubFolderID
And I would like to do that recursively as opposed to creating a new state for each subdirectory
I would suggest, do it with one state and one param -
folderPath
. Becauseui-router
should have all the states defined soon enough, to support url routing. All these unique folderPath could differ, could be dynamic - in the runtime, in app life time.Dynamic
url
parameter - will work always. We just have to parse it in controller and decide next steps. Here is a working example.The state and its param could be like this
Later we can dynamically generate navigation (links) like this:
check that in this example