Skip to content

docs(datepicker): update docs and add examples #7837

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 21, 2017

Conversation

mmalerba
Copy link
Contributor

No description provided.

@mmalerba mmalerba requested review from jelbourn and kara October 17, 2017 00:35
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Oct 17, 2017
### Setting the selected date

The type of values that the datepicker expects actually depends on the particular `DateAdapter` that
you're using in your app. For example when using the `NativeDateAdapter` the datepicker expects
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example -> For example,

you're using in your app. For example when using the `NativeDateAdapter` the datepicker expects
`Date` objects, and when using the `MomentDateAdapter` it expects `Moment` objects. You can also
create your own `DateAdapter` that works with whatever date type you want. (For more information
about this see the section on
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

about this -> about this,

### Disabling parts of the datepicker

As with any standard `<input>`, it is possible to disable the datepicker input by adding the
`disabled` property. By default the `<mat-datepicker>` and `<mat-datepicker-toggle>` will inherit
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default -> By default,

formats.

If you want use one of the `DateAdapters` that ships with Angular Material, but use your own
`MAT_DATE_FORMATS` you can import the `NativeDateModule` or `MomentDateModule`. These modules are
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAT_DATE_FORMATS you can -> MAT_DATE_FORMATS, you can

disabled: FormGroup;

constructor(fb: FormBuilder) {
this.disabled = fb.group({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you using this FormGroup anywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh nope, I was originally gonna do something else for this example and that was leftover

templateUrl: 'datepicker-locale-example.html',
styleUrls: ['datepicker-locale-example.css'],
providers: [
// The locale would typically be provided on the root module of your application, we do it at
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

application, we do -> application. We do

@kara kara removed their assignment Oct 17, 2017
@mmalerba
Copy link
Contributor Author

comments addressed

Copy link
Contributor

@kara kara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mmalerba
Copy link
Contributor Author

e2e app is broken, probably some moment / material-date-adapter issue, will look into it

@mmalerba
Copy link
Contributor Author

tests are good now (well as good as master...)

@mmalerba mmalerba added the action: merge The PR is ready for merge by the caretaker label Oct 17, 2017
@mmalerba
Copy link
Contributor Author

fixes #7464

containing the `startAt` date.

<!-- example(datepicker-start-view) -->

### Setting the selected date

The type of values that the datepicker expects actually depends on the particular `DateAdapter` that
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type of values that the datepicker expects depends on the type of `DateAdapter` provided in your
application. The `NativeDateAdapter`, for example, works directly with plain JavaScript `Date` objects.
When using the `MomentDateAdapter`, however, the values will all be Moment.js instances. This use of the
adapter pattern allows the datepicker component to work with any arbitrary date representation with a custom `DateAdapter`.
See [_Choosing a date implementation_](#choosing-a-date-implementation-and-date-format-settings) for more information.

about this, see the section on
[choosing a date implementation](#choosing-a-date-implementation-and-date-format-settings)).

Depending on the `DateAdapter` you're using, the datepicker may automatically deserialize certain
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Depending on the DateAdapter you're using" -> "Depending on the DateAdapter being used"

date formats for you as well. For example, both the `NativeDateAdapter` and `MomentDateAdapter`
allow [ISO 8601](https://tools.ietf.org/html/rfc3339) strings to be passed to the datepicker and
automatically converted to the proper object type. This can be convenient when binding data directly
from your backend to the datepicker. However, when possible, you should pass the appropriate object
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, when possible, you should pass the appropriate object type.

If we officially support it should we need to recommend against it?


The input's native `(input)` and `(change)` events will only trigger due to user interaction with
the input element; they will not fire when the user selects a date from the calendar popup. Because
of this limitation, the datepicker input also has support for `(dateInput)` and `(dateChange)`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't use the word "limitation", since that's the expected native behavior.


<!-- example(datepicker-api) -->

### Internationalization

In order to support internationalization, the datepicker supports customization of the following
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you're here, change this to
"Internationalization of the datepicker is configured via three aspects:"
?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, it's odd that the headers directly under this list don't align with the points here.

* Support for custom time zones
* Infinite scrolling through calendar months
* Easier year selection
* Custom views for the calendar popup
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would omit the future work section here; we don't include it in any of the other docs. Do we have issues to track these?

@mmalerba mmalerba removed the action: merge The PR is ready for merge by the caretaker label Oct 17, 2017
@mmalerba
Copy link
Contributor Author

comments addressed

Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jelbourn jelbourn added the action: merge The PR is ready for merge by the caretaker label Oct 17, 2017
@tinayuangao tinayuangao merged commit 206d9e0 into angular:master Oct 21, 2017
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants