DateInputDirective class

A decorator which makes the decorated input automatically parse localized dates.

When a user types in a date, dates with 2-digit years are handled specially. E.g. 7/7/77 is interpreted as July 7, 1977, not July 7, 77. This logic looks 20 years into the future: right now (August 2015), "35" is interpreted as 2035 but "36" is interpreted as "1936". Next year, "36" will start to be interpreted as 2036.

The value of the decorated input is two-way bound with the date attribute:

  • When that date changes, the input will update to display it.
  • When the input's text is changed (only on "change" events, not on each keypress), the decorator will try to parse that text as a date. If it's a valid date, it'll update the selected date to reflect that.

This hijacks the input's on-change property, so don't specify that on the input, or this won't work.

Annotations
  • @Directive(selector: 'material-input[dateParsing]')

Constructors

DateInputDirective(@Optional() @Inject(datepickerClock) Clock? clock, Clock legacyClock, MaterialInputComponent _input)

Properties

date Date?
The selected date.
getter/setter pair
dateChange Stream<Date?>
Fired when a valid date value is entered.
no setter
dateFormat ↔ DateFormat?
The DateFormat used to format dates. When isMonthInput is false, this defaults to yMMMd, e.g. "Jul 31, 2015". When isMonthInput is true, this defaults to yMMM, e.g. "Jul 2015".
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
isMonthInput bool
If true, the control is used for inputting months rather than specific days. This impacts both how dates are parsed and how they may be altered to fit to the beginning or end of the selected month (depending on rangeEnd).
getter/setter pair
maxDate Date
The latest recognized date, inclusive. Defaults to Dec 31, 9999 -- i.e., limited to 4-digit years.
getter/setter pair
minDate Date
The earliest recognized date, inclusive. Defaults to Jan 1, 1000 -- i.e., limited to 4-digit years.
getter/setter pair
rangeEnd bool
Controls whether entered dates are snapped to the beginning of the specified month (false), or to the end of the specified month (true).
no getter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

dateIsTooEarlyMsg(String minimumDate) String
dateIsTooLateMsg(String maximumDate) String
ngOnDestroy() → void
Executed before the directive is removed from the DOM and destroyed.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

invalidDateMsg String
final