Express JS:参数未定义
Express JS : Params undefined
我有以下路线在我的express js
app.get('/fetchnotes/:id', function(req, res) {
var id = req.params.id;
console.log(id);
connection.query('SELECT * from dn_notes where id=?',[id], function(err, rows, fields) {
if (!err) {
res.json(rows);
} else {
console.log(err);
}
});
});
和我有以下代码在HTML文件中,这将调用fetchnotes参数
<a class="item item-body" href="#/app/fetchnotes/{{notes.id}}">
{{notes.detail}}
</a>
app.js
.state('app.fetchsinglenote', {
url: '/fetchnotes/:notelistid',
views: {
'menuContent': {
templateUrl: 'templates/notelists.html',
controller: 'SingleNoteListCtrl'
}
}
});
controller.js
.controller('SingleNoteListCtrl', function($scope, $state, $resource, $stateParams ) {
$scope.fetchnotes = {};
var id = $stateParams .id;
var Fetchnotes1 = $resource('http://localhost:8080/fetchnotes/'+ id);
Fetchnotes1.query(function(results) {
$scope.fetchnotes = results;
})
})
节点服务器通过8080端口运行。
然而,我在我的express js文件中的console.log(id);
行从控制台获得undefined
的值。问题在哪里?
$resource('http://localhost:8080/fetchnotes/:notelistid', {notelistid: '@_id'},试着这样发送
相关文章:
- 要求未定义JS回调参数
- 为什么grunt contrib connect的中间件选项的第三个参数是未定义的
- 角度指令控制器:参数不是函数,未定义
- AngularJS-参数'菜单Ctrl'不是函数,未定义
- JS和Jquery函数参数未定义
- 为什么我传递给函数的参数未定义
- setInterval调用具有未定义参数的函数
- 将对象作为参数传递后的未定义属性
- 错误:[ng:areq]参数'CompanyCtrl'不是函数,未定义
- Javascript-函数获取数组元素参数未定义/为null
- 为什么我的函数参数说是未定义的
- 控制器错误:参数不是函数,未定义
- JS函数返回函数供以后使用-未定义参数
- 错误:参数'ContactController'不是函数,未定义
- 在ColdFusion中表单范围中未定义AJAX请求的发布参数
- JavaScript 事件中的未定义参数
- 向函数传递未定义参数-检查变量是否存在
- 在javascript中,如何区分没有参数传递和未定义参数传递
- Javascript Uncaught ReferenceError:未定义参数
- 对快速路由使用回调函数时的未定义参数