ngb-datepicker中的值转换为日期失败

时间:2018-07-09 12:05:27

标签: angular mongodb date mongoose nodes

我在角度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

0 个答案:

没有答案