私は Express と Angular を使用して Node アプリに取り組んでいます。ルーティングに Angular を使用しており、ルートを次のように設定しています。
app.config(['$routeProvider', function ($routeProvider) {
$routeProvider.when('/', {
templateUrl: '/partials/main'
//controller: 'IndexController'
}).when('/discover', {
templateUrl: '/partials/discover'
}).when('/user/home', { //HERES THE PROBLEM CHILD!!!!!
templateUrl: '/partials/user/home'
}).otherwise({
redirectTo: '/'
});
}]).config(['$locationProvider', function ($locationProvider) {
$locationProvider.html5Mode(true);
}]);
今、私が電話しようとするたびに/user/home
-ページは無限ループに入り、コントローラーをリロードし続けます。ノード コンソールでpartials/user/home
、Jade ファイルが確実に含まれているページが呼び出されたことを確認できます。私は他の投稿をチェックしましたが、それらのほとんどは/
部分パスの先頭にあるお尻で解決されていますが、ここでは役に立ちませんでした。サブディレクトリのないディレクトリに転送home.jade
すると、ページが正常に読み込まれます。/partials
何か案は?
更新:パーシャルのサブディレクトリにパーシャルをロードしようとすると、無限ループが発生するようです。
リクエストごと:
ノード -- App.js:
app.get('/', routes.index);
app.get('/partials/:name', routes.partials);
app.get('*', routes.index);
そしてroutes/index.js
exports.index = function(req, res) {
res.render('index', { title: 'Open Innovation Station' });
}
exports.partials = function(req, res) {
res.render('partials/' + req.params.name);
}