如何根据角度 8 中的日期选择将值绑定到对象数组

How to bind value to the array of object based on date selection in angular8

我有对象数组,如果日期是从日期时间日历中选择的,则该值不会绑定到该对象,但是如果我手动更改日期则它可以工作,但是如果我 select从日历中,该值是 nit 绑定。我试过 (change) 和 (ngModelChange),但都没有用。

HTML:

<div class="col-6 
            *ngFor="let restrictValue of Restrictions;let i = index">

            <div class="form-group">
              <input type="text" class="form-control onlyDateTime" placeholder="MM/DD/YYYY HH:MM AM/PM"
                [disabled]="!restrictValue.boolValue" [(ngModel)]="restrictValue.datetime" (change)="dateRestriction($event,restrictValue)" (click)="dateRestriction($event, i)"
                [ngModelOptions]="{standalone: true}" >
            </div>
          </div>

TS:

dateRestriction(event,restriction) {
       $('.onlyDateTime').datetimepicker();
      $('.onlyDate').datetimepicker({
        format: 'L'
      });
   $('.onlyDateTime').datetimepicker(
    ).on('dp.change', (e)=>{
      const date = e.date;

      });
  }

DEMO

试试这个:

dateRestriction(event, restriction) {
    $(".onlyDateTime").datetimepicker();
    $(".onlyDate").datetimepicker({ format: "L" });
    $(".onlyDateTime")
      .datetimepicker()
      .on("dp.change", e => {
        const date = e.date;
        this.Restrictions[restriction].datetime = date.format("DD/MM/YYYY HH:mm:ss A");
      });
  }