Giter Club home page Giter Club logo

angular-datetime-filter's Introduction

angular-datetime-filter

AngularJS Datetime Filter

AngularJS filters for filtering arrays. The filters may be used just like the native filter-filter.

upcoming:date filters for array elements which date property is in the future.

past:date filters for array elements which date property is in the past.

##Install Install with bower:

bower install angular-datetime-filter

Add a <script> to you index.html:

<script src="/bower_components/angular-datetime-filter/dist/angular-datetime-filter.js"></script>

And add datetimeFilter as a dependency for your app:

angular.module('myApp', ['datetimeFilter']);

##How to use ###Array of objects

$scope.items = [
    {'date': '2014/01/02', 'name': 'one'},
    {'date': '2013/12/24', 'name': 'two'},
    {'date': '2014/10/03', 'name': 'three'},
    {'date': '2012/01/01', 'name': 'four'},
    {'date': '1970/01/01', 'name': 'five'}
];
<ul>
    <li ng-repeat="item in items | upcoming:date">{{item.name}}
</ul>

Assuming today is 2014/01/01; This should result in:

  • one
  • three

Whereas this:

<ul>
    <li ng-repeat="item in items | past:date">{{item.name}}
</ul>

Should result in:

  • two
  • four
  • five

###Simple datetime array

$scope.items = [
    '2014/01/02',
    '2013/12/24',
    '2014/10/03',
    '2012/01/01',
    '1970/01/01'
];
<ul>
    <li ng-repeat="item in items | upcoming">{{item}}
</ul>

Should result in:

  • 2014/01/02
  • 2014/10/03

Documentation

Angular module datetimeFilter

###upcoming

{{ filter_expression | upcoming : dateField }}
$filter('upcoming')(array, dateField)

array array - The source array

dateField string (optional) - the datetime property, defaults to none ###past

{{ filter_expression | past : dateField }}
$filter('past')(array, dateField)

array array - The source array

dateField string (optional) - the datetime property, defaults to none ###datetimeFilter

{{ filter_expression | datetimeFilter : dateField : mode }}
$filter('datetimeFilter')(array, dateField, mode)

array array - The source array

dateField string (optional) - the datetime property, defaults to none

mode string (optional) - Either 'past' or 'upcoming', defaults to 'upcoming'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.