Skip to content
This repository was archived by the owner on Nov 3, 2024. It is now read-only.

esplanning/momentjs-angular-module

 
 

Repository files navigation

Angular Moment.js Module

Build Status Code Climate Test Coverage

An AngularJS module to add Moment.js functionality to Angular. No jQuery necessary!

Requirements

  • [Moment.js] 1 v2.3.0+ (v2.5.1+ recommended)
  • [AngularJS] 2 v1.2.0+

Documentation

Please see the [Project Wiki] [3] for documentation. [3]: https://github.com/orcasnet/momentjs-angular-module/wiki

Directive

<input type="moment"
       ng-model="{string}"
       [format="{string}"]
       [model-format="{string}"]
       [view-format="{string}"]
       [min="{expression}"]
       [max="{expression}"]
       [step="{string}"]>
</input>

Parameters

Param Type Default Details
format (optional) String Specify a single Moment format for both the model and view values. Overridden if modelFormat or viewFormat is set. Sets date validation error key if the date is invalid.
modelFormat (optional) String $moment.$defaultModelFormat Specify a Moment format for the model value. Sets date validation error key if the model date is invalid.
viewFormat (optional) String $moment.$defaultViewFormat Specify a Moment format for the view value. Sets date validation error key if the view date is invalid.
min (optional) Expression Sets min validation error key if the date value is before the min date. Expected value is a date string or an array of a date string and a Moment format to parse it with.
max (optional) Expression Sets max validation error key if the date value is after the max date. Expected value is a date string or an array of a date string and a Moment format to parse it with.
step (optional) String 1 day Specify a quantity and a unit of time to step the date by on mouse wheel up/down, up/down arrow keys, or plus/minus keys. Pressing shift causes the date to step by one greater or lesser unit of time.

Note that all parameters can be bound data-bound and dynamic. If modelFormat is changed, the view value will be reparsed to provide the new format for the model value, and conversely if viewFormat is changed.

About

An AngularJS module to add Moment.js functionality to Angular

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 98.4%
  • HTML 1.6%