feat(MatDatePicker): adding ability to use flexable format
- 主要言語
- TypeScript
- スター
- 25k
- フォーク
- 6.8k
- 平均マージ
- 1日 8時間
- マージ済み PR(30日)
- 91
説明
### Feature Description
I'm just wondering if we can add the feature of dateFormat to the datepicker
datepicker-input-base.ts
```
@Input displayFormat: string|undefined|null;
@Input parseFormat: string|undefined|null;
```
and in the code:
```
protected _formatValue(value: D | null) {
**const format = this.displayFormat ?? this._dateFormats.display.dateInput;**
this._elementRef.nativeElement.value =
value != null ? this._dateAdapter.format(value, **format**) : '';
}
_onInput(value: string) {
const lastValueWasValid = this._lastValueValid;
**const format = this.parseFormat?? this._dateFormats.parse.dateInput;**
let date = this._dateAdapter.parse(value, **format** );
// ... remaining code
}
```
### Use Case
in this case we can alow different pasing/display format in the same app
the first input will use custom format and the second one use the default one.
both are in the same component
```
Choose a date
DD/MM/YYYY
Choose a date
MM/DD/YYYY
```
コントリビューションガイド
調査の方向性
datepicker-input-base.ts から始め、date adapter と既存の date-format 設定を通じて _formatValue と _onInput を追跡します。例で説明されている入力ごとの displayFormat と parseFormat の動作を定義し、その後、デフォルトのパスを変更せずにカスタム形式とデフォルト形式が共存することを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- angular, typescript
- 領域
- frontend
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100