I would suggest, do it with one state and one param - folderPath
. Because ui-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 state definition is always an issue (if states are defined in app.run() it could happen that user comes to url which is not defined yet - otherwise
is used... bad)
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
.state('files', {
url: '/files/{folderPath:[a-zA-Z0-9/]*}',
templateUrl: 'tpl.files.html',
controller: 'FileCtrl'
});
Later we can dynamically generate navigation (links) like this:
<a href="#/files/Folder1">
<a href="#/files/Folder1/SubFolder1/">
<a href="#/files/Folder1/SubFolder1/SubFolderA">
<a href="#/files/Folder1/SubFolder1/SubFolderB">
<a href="#/files/Folder1/SubFolder2/SubFolderX">
check that in this example
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…