p-calendar primeng无法使用ngmodel和pipe

Aid*_*ard 5 typescript primeng angular angular5

我正在尝试将 ng-prime 中的 p-calendar 与 ngmodel 结合使用来绑定来自服务器的日期

 <p-calendar [(ngModel)]="selectedDate"
             [locale]="es"
             [hidden]="!editing"
             dateFormat="d/mm/yy"
             appendTo="body"
             class="pos-cal mar-left-txt"
             [(ngModel)]="currentUserData.person.dateOfBirth">
 </p-calendar>

 <p [hidden]="editing">
     {{currentUserData.person.dateOfBirth | date: 'dd/MM/yyyy'}}
 </p>
Run Code Online (Sandbox Code Playgroud)

这段代码做了我想要的事情,我只是有一个问题。我已将所选日期设置为今天,但这不是我希望用来显示的日期。我想在 p-calendar 上显示出生日期

当我从日历中选择一个日期时,它会绑定到该段落,通常我只会使用管道,但它不起作用

mal*_*awi 0

我发现的唯一情况是当你没有 inilized 时selectedDate,尝试设置selectedDatecurrentUserData.person.dateOfBirth

在我的示例中我只是设置为当前日期

模板

<p-calendar [(ngModel)]="selectedDate"
             [hidden]="!editing"
             dateFormat="d/mm/yy"
             appendTo="body" (onBlur)="editing = !editing"  >
 </p-calendar>

 <p [hidden]="editing" (click)="editing = !editing">
     {{selectedDate | date: 'dd/MM/yyyy'}}
 </p>
Run Code Online (Sandbox Code Playgroud)

成分

  selectedDate;
  editing = false
  constructor() {
    this.selectedDate = new Date();
  }
Run Code Online (Sandbox Code Playgroud)

演示