对于检索数据,您需要实现如下逻辑:
html/jade file:
// USER INFO
#userInfo
h2 User Info
p
strong Name:
| <span id='userInfoName'></span>
br
strong Age:
| <span id='userInfoAge'></span>
br
strong Gender:
| <span id='userInfoGender'></span>
br
strong Location:
| <span id='userInfoLocation'></span>
// /USER INFO
js中对应的函数代码: // 显示用户信息 function showUserInfo(event) {
// Prevent Link from Firing
event.preventDefault();
// Retrieve username from link rel attribute
var thisUserName = $(this).attr('rel');
// Get Index of object based on id value
var arrayPosition = userListData.map(function(arrayItem) { return arrayItem.username; }).indexOf(thisUserName);
// Get our User Object
var thisUserObject = userListData[arrayPosition];
//Populate Info Box
$('#userInfoName').text(thisUserObject.fullname);
$('#userInfoAge').text(thisUserObject.age);
$('#userInfoGender').text(thisUserObject.gender);
$('#userInfoLocation').text(thisUserObject.location);
};
以下是参考文档:
http ://cwbuecheler.com/web/tutorials/2014/restful-web-app-node-express-mongodb/
一旦您的应用程序在本地运行,您可以通过 cloudfoundary 工具将其推送到 Bluemix:http:
//clouds-with-carl.blogspot.in/2014/02/deploy-minimal-nodejs-application-to.html
希望能帮助到你。