这是 Angular Bootstrap 日期选择器的错误吗?
Is this a bug with the Angular Bootstrap date picker?
如果我有一个 Angular bootstrap 格式为 "DD/MM/YYYY" 的日期选择器并用 ngIf 隐藏它,当它默认返回 "MM/DD/YYYY" 格式时再次显示。
<button (click)="show = !show">{{ show ? 'Hide' : 'Show' }}</button><br>
<input bsDatepicker [bsConfig]="{ dateInputFormat: 'DD/MM/YYYY' }" type="text" [(bsValue)]="date" *ngIf="show">
查看此 StackBlitz https://stackblitz.com/edit/angular-uwa2fs
有人能想出解决办法吗?
一种解决方法是仅在 DOM 中隐藏日期选择器,而不是 destroying/recreating。所以,而不是 *ngIf="show"
,[class.hidden]="!show"
(和 css:.hidden { display: none; }
)。
https://stackblitz.com/edit/angular-eudgh3?file=src/app/app.component.html
如果我有一个 Angular bootstrap 格式为 "DD/MM/YYYY" 的日期选择器并用 ngIf 隐藏它,当它默认返回 "MM/DD/YYYY" 格式时再次显示。
<button (click)="show = !show">{{ show ? 'Hide' : 'Show' }}</button><br>
<input bsDatepicker [bsConfig]="{ dateInputFormat: 'DD/MM/YYYY' }" type="text" [(bsValue)]="date" *ngIf="show">
查看此 StackBlitz https://stackblitz.com/edit/angular-uwa2fs
有人能想出解决办法吗?
一种解决方法是仅在 DOM 中隐藏日期选择器,而不是 destroying/recreating。所以,而不是 *ngIf="show"
,[class.hidden]="!show"
(和 css:.hidden { display: none; }
)。
https://stackblitz.com/edit/angular-eudgh3?file=src/app/app.component.html