我有一个GET路线,如下所示:
employee.hbs
我的<div class="row">
<div class="col-md-12">
<h2>{{employee.firstName}} {{employee.lastName}} - Employee: {{employee.employeeNum}}</h2>
<hr />
<form method="post" action="/employee/update">
<fieldset>
... ... ...
视图等待服务器如下,
console.log(data)
我已添加/employee/5
以确定并验证来自相应员工的正确数据是否已呈现。即路径[ { employeeNum: 5,
firstName: 'Ysabel',
lastName: 'Collyns',
email: 'ycollyns4@myCompany.com',
SSN: '930-71-9325',
addressStreet: '529 Grim Lane',
addresCity: 'New York',
addressState: 'NY',
addressPostal: '62205',
maritalStatus: 'married',
isManager: true,
employeeManagerNum: null,
status: 'Full Time',
department: 6,
hireDate: '4/18/2011' } ]
正确返回,
<h2>Ysabel Collyns - Employee: 5</h2>
有什么想法?不知道我在这里失踪了什么。而不是返回
<h2> - Employee: </h2>
返回
android:parentActivityName
答案 0 :(得分:0)
尝试使用<h2>{{employee.0.firstName}} {{employee.0.lastName}} - Employee: {{employee.0.employeeNum}}</h2>
,因为对象在数组中。
希望这有帮助。
答案 1 :(得分:0)
问题出在我的一个模块函数中,
正确的版本:
module.exports.getEmployeeByNum = function(num) {
return new Promise((resolve, reject) => {
var temp = [];
let j = 0;
for (let i = 0; i < employees.length; i++) {
if (employees[i].employeeNum == num) {
temp[j] = employees[i];
j++;
}
}
if (temp.length == 0) {
reject("No results");
} else {
resolve(temp[0]);
}
});
}
问题是我在调用resolve(temp);
而不是resolve(temp[0]);