In my angularjs app, there is a concept of 'project'. Each project can contain 0 or more folders, and each of those folders can contain 0 or more subfolders. Each of the subfolders, in turn, can contain 0 or more sub-subfolders and so on. There is no actual limit on the amount of folder levels in the hierarchy.
I want to map each of the folder levels to a UIRouter state level.
E.g.,
URL State name
http://localhost:8079/projects/1122024 -> _.projects.view
http://localhost:8079/projects/1122024/folders/123890 -> _.projects.view.folder
http://localhost:8079/projects/1122024/folders/123890/547938 -> _.projects.view.folder.folder
http://localhost:8079/projects/1122024/folders/123890/547938/124890 -> _.projects.view.folder.folder.folder
etc.
Is it possible to declare such an endless hierarchy in UIRouter? If yes, then how? The only idea I have now is to use string.split, like following code - but I really don't feel like it's the correct way to do it. Any ideas?
.state('_.projects.view', {
url: '/{projectId:int}'
})
.state('_.projects.view.folders', {
url: '/folders/{folderIds}',
resolve: {
folderIdTree: function($stateParams) {
$stateParams.folderIds.split('/');
}
}
}