title: Express.js and AngularJS routing parameters
body: <p>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:</p>
  
  <pre><code>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);
  });
  </code></pre>
  
  <p>And Angular has routes defined with 0-2 parameters:</p>
  
  <pre><code>$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);
  </code></pre>
  
  <p>/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).</p>
  
  <p>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?</p>
  
  <p>You can download the project <a href="https://www.dropbox.com/s/5y32is1lf9yimx7/routing.zip" rel="nofollow">here</a>, if you want to examine it.</p>
  
  <p>Thanks in advance.</p>