Skip to content

Commit

Permalink
docs(#163): action button sample
Browse files Browse the repository at this point in the history
add an action button sample to the application.
also document its usage in `README.md`.
  • Loading branch information
bbortt committed Mar 15, 2023
1 parent 9eacd4c commit 0463774
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 24 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,18 @@ imports: [
</form>
```

You can optionally add action buttons inside the `mat-datetimepicker`.

```html
<mat-datetimepicker ...>
<mat-datetimepicker-actions
[cancelButtonLabel]="'Cancel'"
[confirmButtonLabel]="'Confirm'"
>
</mat-datetimepicker-actions>
</mat-datetimepicker>
```

## Date formatting

In order to change the default input/output formats, a custom instance of `MAT_DATETIME_FORMATS` needs to be provided in
Expand Down
70 changes: 46 additions & 24 deletions src/app/date.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ <h2>
required
/>
<mat-error *ngIf="group.get('dateTime').errors?.required"
>required</mat-error
>
>required
</mat-error>
<mat-error *ngIf="group.get('dateTime').errors?.matDatepickerMin"
>min</mat-error
>
>min
</mat-error>
<mat-error *ngIf="group.get('dateTime').errors?.matDatepickerMax"
>max</mat-error
>
>max
</mat-error>
</mat-form-field>
<mat-form-field>
<mat-datetimepicker-toggle
Expand All @@ -58,14 +58,14 @@ <h2>
placeholder="DateTime Year selector"
/>
<mat-error *ngIf="group.get('dateTimeYear').errors?.required"
>required</mat-error
>
>required
</mat-error>
<mat-error *ngIf="group.get('dateTimeYear').errors?.matDatepickerMin"
>min</mat-error
>
>min
</mat-error>
<mat-error *ngIf="group.get('dateTimeYear').errors?.matDatepickerMax"
>max</mat-error
>
>max
</mat-error>
</mat-form-field>
<mat-form-field>
<mat-datetimepicker-toggle
Expand Down Expand Up @@ -107,8 +107,8 @@ <h2>
placeholder="Time AM/PM"
/>
<mat-error *ngIf="group.get('timeAMPM').errors?.required"
>required</mat-error
>
>required
</mat-error>
</mat-form-field>
<mat-form-field>
<mat-datetimepicker-toggle
Expand Down Expand Up @@ -190,14 +190,14 @@ <h2>
type="datetime"
></mat-datetimepicker>
<mat-error *ngIf="group.get('mintest').errors?.required"
>required</mat-error
>
>required
</mat-error>
<mat-error *ngIf="group.get('mintest').errors?.matDatepickerMin"
>min</mat-error
>
>min
</mat-error>
<mat-error *ngIf="group.get('mintest').errors?.matDatepickerMax"
>max</mat-error
>
>max
</mat-error>
</mat-form-field>
<mat-form-field>
<input
Expand All @@ -220,11 +220,11 @@ <h2>
type="datetime"
></mat-datetimepicker>
<mat-error *ngIf="group.get('filtertest').errors?.required"
>required</mat-error
>
>required
</mat-error>
<mat-error *ngIf="group.get('filtertest').errors?.matDatepickerFilter"
>filter</mat-error
>
>filter
</mat-error>
</mat-form-field>
<mat-form-field>
<input
Expand Down Expand Up @@ -268,4 +268,26 @@ <h2>
type="datetime"
></mat-datetimepicker>
</mat-form-field>
<mat-form-field>
<mat-datetimepicker-toggle
[for]="datetimePickerWithActions"
matSuffix
></mat-datetimepicker-toggle>
<mat-datetimepicker
#datetimePickerWithActions
type="datetime"
openOnFocus="true"
timeInterval="5"
>
<mat-datetimepicker-actions></mat-datetimepicker-actions>
</mat-datetimepicker>
<input
matInput
formControlName="start"
[matDatetimepicker]="datetimePickerWithActions"
required
autocomplete="false"
placeholder="With Action Buttons"
/>
</mat-form-field>
</form>

0 comments on commit 0463774

Please sign in to comment.