Expressを使用してnode.jsサーバーに支えられたAngularJSアプリでパラメーターを使用していくつかのルートを設定しようとしています。ノードは、明示的に検出されていないすべてのものをすべてキャッチするようにルーティングするように設定されています。
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);
});
また、Angular には 0 ~ 2 個のパラメーターで定義されたルートがあります。
$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 は機能しますが、/otherpage/123 がキャッチ オールにヒットしている間 (コンソール メッセージが表示されます)、ブラウザーでクラッシュします。何もレンダリングされず、Chrome に問題があると表示されます (IE レンダリングでは何も表示されません)。
パラメータが渡されていないことは理解できますが、少なくともそれがないとルートが発生しないのはなぜですか? Express.js と AngularJS で URL パラメーターを設定するにはどうすればよいですか?
プロジェクトを調べたい場合は、ここからプロジェクトをダウンロードできます。
前もって感謝します。