Git Product home page Git Product logo

ngrange's Introduction

ngRange

A simple AngularJS filter to allow range iteration in an ng-repeat directive.

See an example (and view source to see the implementation)

Why?

Some times you need to have an ng-repeat do a given number of iterations that is not intrinsically tied to an object or array in the scope. This is an edge case not supported by AngularJS, so this module is a stand-in.

How does it work?

A range is used as follows:

<div ng-repeat="n in [5, 10] | range">The value of n is {{n}}</div>"

This div will be repeated for values of n from 5 to 9 inclusive.

If only a single argument is given, an implicit 0 is inserted as the lower bound. This allows syntax like this:

<div ng-repeat="n in [10] | range">The value of n is {{n}}</div>"

Which will repeat for values of n from 0 to 9.

The upper bound of a range is not inclusive.

Installation

bower install ngRange

make sure ngRange/dist/ngRange.js is loaded before your angular module. ngRange is wrapped in the Universal Module Definition so it supports AMD, CommonJS, and plain ol' global declaration via script tag.

Make your angular module require the 'ngRange' module and then you're ready to use the range filter in your templates.

Development

You'll need to clone this repository, have gulp installed globally (via npm install -g gulp) and then run npm install.

Once you're set up run gulp build to convert the source to a js file in /dist or simply run gulp to build continuously with a watcher. The code in /example points to the version in /dist as a dead-simple way of testing.

Future

Not much of a roadmap for something this simple. Issues and pull requests however, are welcome.

ngrange's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

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.