我在角度5中使用ngb-datepicker(ng-bootstrap)。我试图将选定的日期输入到mongodb中,但出现以下错误
message: 'Cast to Date failed for value "{ year: 2018, month: 7, day
}" at path "notess"',
name: 'CastError',
stringValue: '"{ year: 2018, month: 7, day: 3 }"',
kind: 'Date',
value: [Object],
path: 'notess',
reason: [Object] } },
_message: 'Datevalidation failed',
name: 'ValidationError' }
HTML
<form [formGroup]="addDateForm">
<ngb-datepicker formControlName="event-date" name="event-date" ></ngb-datepicker>
</form>
模型
const dateSchema = new mongoose.Schema({
event-date:{type: Date} ,
});
const Event= mongoose.model('Event', noteSchema);
export default Event