我有这种获取功能的角度方法。我只需要具有我通过参数传递的releaseid的功能。
getFeatures() {
this.route.params.subscribe(params => {
this.featureService.getFeatures(params['releaseid']).subscribe(res => {
this.features = res;
})
});
}
我的服务(featureService):
getFeatures(releaseId) {
const uri = 'http://localhost:4000/features';
return this
.http
.get(uri, {params: {releaseId: releaseId}})
.map(res => {
return res;
});
}
我的nodejs路由
featureRoutes.route('/features').get(function (req, res) {
console.log(req.body.params);
});
但是req.body.params是未定义的。
对此有何帮助?
答案 0 :(得分:1)
试试这个
服务(featureService):
getFeatures(releaseId) {
const uri = 'http://localhost:4000/features?releaseId=' + releaseId;
return this.http.get(uri);
}
Nodejs route:
featureRoutes.route('/features').get(function (req, res) {
console.log(req.params); // should contain your releaseId
});
您现在应该能够获得节点后端中的releaseId
。
答案 1 :(得分:0)
我找到了。在我必须做的路线中:
console.log(req.query.releaseId)