我是Angular的新手,我正在尝试实现事件的日历。 我正在使用Angular UI日历。当我发布数据时,它会发布,但它会给出错误。预期数组,但收到
POST方法
$http({
method : 'POST',
url : '/api/appointment',
data : $scope.appointment
}).success(function(data) {
console.log(data);
}).error(function(err) {
console.log(err);
});
预计数组,但收到的:
{ "__v": 0,
"visitType": "Referral",
"timeDuration": "900000",
"patientId": "BMSHT002",
"doctorId": "BMSHTDOC60",
"_id": "5833da8d9889edd037a54c30",
"eventSources": [{
"title": "Patient Name : Vignesh\t Age :10\t Gender : male\t Email Id : [email protected]\n Appointment Type : Referral\n Doctor Name : Demo 1",
"start": "2016-11-21T04:30:00.000Z",
"end": "2016-11-21T04:45:00.000Z",
"_id": "5833da8d9889edd037a54c31"
}]
}
我知道,这是一个JSON数据,但我不是如何解决这个问题不太清楚。有人能帮我解决这个问题吗?
这同时提前发布数据
var appointmentSchema = mongoose.Schema({
patientId : String,
doctorId : String,
visitType : String,
timeDuration : String,
eventSources: [{
title : String,
start : Date,
end : Date
}]
});
节点JS代码
router.route('/appointment')
.post(function(req, res) {
var appointmentData = req.body;
var appointments = new Appointment(appointmentData);
console.log(appointments);
appointments.save(function(err, appointment) {
if (err)
throw err;
res.send(appointment);
})
})
感谢而是 'res.send' 的
Just t o澄清;您是否通过Angular UI Calendar发送apointmentSchema?此外,也许编辑您的帖子,包括实际的帖子方法。 – onmyway
发布您从Angular传递的输入和构建约会对象的nodejs代码? – Aruna
@onmyway - 模式来自mongooseJS。这是通过其将数据发布到我的数据库的架构,它工作得很好。 – Vignesh