0

I'm playing with angular trying to create some routes without specifying statically the paths

I have the following ng-routes now:

route
.when("path/of/first/file",{templateUrl: "path/of/first/file.html"})
.when("path/of/second/file",{templateUrl: "path/of/second/file.html"})
.when("path/of/third/file",{templateUrl: "path/of/third/file.html"})

As you can see in this example there's a fixed rule for each file:

path/of/%dynamic_path%/file  -> path/of/%dynamic_path%/file.html

So i should have something like a regexp:

route.when("path/of/(.*)/file",{templateUrl: "path/of/$1/file.html"});

I want be able to add paths without having to specify them in the router configuration ( suppose I have thousands of files ). Is there something that will allow me to do this in angular ng-route or ui-route?

Joseph
  • 1,029
  • 13
  • 26

1 Answers1

0

You want dynamic routing, see this – RamblinRose

Armali
  • 18,255
  • 14
  • 57
  • 171