I'm trying to set up some routes with parameters in an AngularJS app backed by a node.js server using express. Node is set up to route everything that isn't explicitely found to a catch all:
app.use(express.bodyParser());
app.use(app.router);
app.use(express.static(__dirname + "/public"));
app.use(function(request, response)
{
console.log("catch all");
writeFile("/public/index.htm", request, response);
});
And Angular has routes defined with 0-2 parameters:
$routeProvider
.when("/",
{
templateUrl: "home.htm"
})
.when("/otherpage",
{
templateUrl: "otherpage.htm"
})
.when("/otherpage/:Var1",
{
templateUrl: "otherpage.htm"
})
.when("/otherpage/:Var1/:Var2",
{
templateUrl: "otherpage.htm"
})
.otherwise(
{
templateUrl: "home.htm"
});
$locationProvider.html5Mode(true);
/otherpage works, but while /otherpage/123 hits the catch all (I can see the console message), it crashes in the browser. Nothing is rendered and then Chrome says that it has a problem (and IE renders nothing just sits there).
I can understand the parameter not being passed, but why isn't the route at least happening without it? What do I need to do to set up URL parameters with express.js and AngularJS?
You can download the project here, if you want to examine it.
Thanks in advance.