angular-moment-filter

0.1.1 • Public • Published

moment-filter

The filter for angular.js based on moment.js(http://momentjs.com). Forked from dotSlashLu/moment-filter and published to npm.

Installation

  1. Get the dependencies: bower install angular-moment-filter --save or just include index.js anyhow.

  2. Inject moment-filter to your app angular.module('yourModule', ['moment-filter']);

Usage

{{input | moment:"function":"param1":"param2":...}} is equivalent to moment(input).function(param1, param2, ...)

  • input: data valid for moment(), string(e.g. "2014-11-01"), object(e.g new Date), etc. If you need to pass multiple strings as parameter for moment(), use array(e.g. [param1, param2] for moment(param1, param2))

  • function: function in moment().__proto__, e.g. format, fromNow, subtract, etc. (Note, you should pass a function name as a string, use {{str | moment : "fromNow"}} rather than {{str | moment : fromNow}})

  • params: params passed to function, each separated by :

To chain methods, just use another pipe: {{str | moment:"subtract":1:'ms' | moment:"quarter"}} -> moment(str).subtract(1, 'ms').quarter()

Examples

screenshot

See test.html or this Plunker: http://plnkr.co/edit/JXOYvZY7UeRbPxNbPe8i.

References

Readme

Keywords

Package Sidebar

Install

npm i angular-moment-filter

Weekly Downloads

3

Version

0.1.1

License

MIT

Last publish

Collaborators

  • andyperlitch