使用从Angular Material的[matDatepicker]返回的数据附加到POST调用

时间:2018-06-14 19:03:21

标签: javascript html angular typescript angular-material2

我有来自Angular Material

的HTML
> <mat-form-field class="start-date-full-width">   <input matInput
> [matDatepicker]="picker" placeholder="Start Date">  
> <mat-datepicker-toggle matSuffix
> [for]="picker"></mat-datepicker-toggle>   <mat-datepicker
> touchUi="true" #picker></mat-datepicker> </mat-form-field>

当我选择实际日期时,我需要将提供给我的数据设置为 dispStartTs heres the data I'm talking about

到我的TS文件。

这是我到目前为止的代码:

  onUpdatePingIt() {
    let dispMsg = this.pingItMessageForMessageCenter + ' ' + this.pingItMessage;
    let dispStartTs = this.startDatePicker;
    let dispEndTs = '';
    let userId = ;

    this.apiEndPointService.onUpdatePingItMessageBoard(dispMsg, dispStartTs, dispEndTs, userId).subscribe(response => {
      console.log(response)
    });

  }

我该怎么做呢?任何帮助将不胜感激。 我假设我需要制作一个单独的TS文件,甚至可能需要一个服务并手动选择它,然后重新使用该组件。但我可能是错的。请帮忙。

1 个答案:

答案 0 :(得分:0)

如果我理解你的问题,你必须使用[formControl]指令。这是来自 example

material help page.