Reputation: 2887
I have a nested a state that is associated with a file path within a directory. That is, the url for the view is something like /workspace/path/to/my/file.txt
. Right now, simply using /:path
does not work. How can ui-router be configured to accept slashes in the middle of a route?
angular.module('myApp')
.config(function ($stateProvider) {
$stateProvider
.state('workspace.file', {
url: '/:path',
parent: 'workspace',
views: {
fileTabs: {
templateUrl: 'app/workspace/workspace.file/file.html',
}
},
controller: 'WorkspaceFileCtrl'
});
});
Upvotes: 3
Views: 1203
Reputation: 123901
There is a similar Q & A: - Recursive ui router nested views
So, we can use more precise regex def:
.state('workspace.file', {
url: '/files/{folderPath:[a-zA-Z0-9/.]*}',
templateUrl: 'tpl.files.html',
controller: 'FileCtrl'
});
Here is the plunker with an example
Upvotes: 2
Reputation: 64725
You'll have to match using a regex:
url: '/{path:.*}'
Or their shortcut catchall syntax:
url: '/*path'
https://github.com/angular-ui/ui-router/wiki/URL-Routing
Upvotes: 1