应该如何定义模型中的字段dateIni

How should be defined the field dateIni in model

我使用一个字段作为日期:dateIni

因为我将它与 ng-boostrap, and DatePicker 一起使用,所以我必须使用以下格式设置他的日期:

tournament.dateIni = {year: 2017, month: 8, day: 8}

在我的模型中,我将其定义为字符串,但它不一致。我应该如何在我的模型中使用哪种类型定义 dateIni?

是否必须创建另一个名为 Date 的模型,其中包含 3 个字段,或者是否有任何其他方法比 any 更好?

在 ng-bootstrap 库中有一个 NgbDateStruct :

import { NgbDateStruct } from '@ng-bootstrap/ng-bootstrap';

复制自 ng-bootstrap 输入文件:

/**
 * Interface of the model of the NgbDatepicker and NgbInputDatepicker directives
 */
export interface NgbDateStruct {
    /**
     * The year, for example 2016
     */
    year: number;
    /**
     * The month, for example 1=Jan ... 12=Dec
     */
    month: number;
    /**
     * The day of month, starting at 1
     */
    day: number;
}