I want to make an angular site dealing with files where users can navigate around in a file system tree, (like on github: github.com/angular/angular.js/tree/master/path/to/my/file.js
.
I would like to capture that path/to/my/file.js
part of the URL with an angular route:
.when("/files/:myPath", templateUrl: "...", controller: "...")
but as expected, :myPath
only matches up to the next slash.
How can I capture all remaining parts of the URL, including an arbitrary number of slashes?
I found this question that is related, but differs in that my URL is fine to be after the angular hash, e.g. .../index.html#/files/path/to/my/file
.
As of Angular 1.1.5 you can use *path
- see here.
path can contain named groups starting with a star (*name). All characters are eagerly stored in
$routeParams
under the given name when the route matches.For example, routes like /color/:color/largecode/*largecode/edit will match /color/brown/largecode/code/with/slashs/edit
As of Angular 1.3, the syntax is :path*
(credit to DRAX in the comments)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With