如何使用kendo angular ui datepicker获取格式化的日期值

时间:2017-07-22 16:33:17

标签: angular kendo-ui-angular2

我只需要获取日期的格式化值,你能帮助我如何在我的组件文件中实现它

<form [formGroup]="form" (ngSubmit)="onSubmit(form.value)">
      <div class="form-group">
        <label for="symbol">Symbol</label>
        <input [formControl]="symbol" type="text" class="form-control" id="symbol" placeholder="Enter Symbol to filter">
      </div>
      <div class="form-group">
        <div class="row">
          <div class="col-xs-12 col-sm-6 example-col">
            <label for="histFromDate">From</label>
            <kendo-datepicker [formControl]="histFromDate" id="histFromDate" class="form-control" [format]="'MM-dd-yyyy'"></kendo-datepicker>
          </div>
          <div class="col-xs-12 col-sm-6 example-col">
            <label for="histToDate">To</label>
            <kendo-datepicker [formControl]="histToDate" id="histToDate" class="form-control" [format]="'MM-dd-yyyy'"></kendo-datepicker>
          </div>
        </div>
      </div>
      <div class="button-wrapper">
        <button [disabled]="!form.valid" type="submit" class="btn btn-default">Submit</button>
      </div>

    </form>

1 个答案:

答案 0 :(得分:1)

我挖掘了api点击here 并找到以下答案是代码

import { IntlService } from '@progress/kendo-angular-intl';

constructor(private intl: IntlService) {}

private formatValue(value?: Date): string {
    return value ? `${this.intl.formatDate(value, 'd')}` : '';
}