1
我想将一个数组的索引值传递给一个路由,所以我可以使用该id将特定的对象加载到一个详细视图中。AngularJS和ExpressJS路由冲突
控制器,可注入的指数,并改变路径
location.path('/detail/'+index);
$ routeProvider一个处理细节路由
.when('/detail/:index', {
controller: DetailViewCtrl, templateUrl: 'partials/detail'
});
快速脚本处理部分加载
app.get('/partials/:partial', function(req, res) {
return res.render('partials/' + req.params['partial']);
};
如果我通过在5的索引中,我希望URL看起来像“localhost:3000/detail/5”和I在我的浏览器中获取,但服务器返回404错误,试图寻找一些奇怪的URL“localhost:3000/detail/partials/detail”。我不知道在部分来源之前添加的“细节”在哪里。
很高兴知道幕后发生了什么以及如何解决问题。我如何传递路由中的自定义变量,而不是表达怪异?