angular-range-selection-parser

AngularJS module to parse range selection strings from user input

Added by: Sam Deering

GitHub

Repository

espesen/angular-range-selection-parser

Stats

Stars: 1

Watchers: 1

Forks: 0

Author

Esa Toivola
Esa Toivola

Module Description

range-selection-parser

AngularJS module to parse range selection strings from user input, for example '2, 5, 7-9'.

Example:

http://htmlpreview.github.io/?https://github.com/Espesen/angular-range-selection-parser/blob/master/example/example.html

Usage:

Inject service rangeSelectionParser to your controller and then


rangeSelectionParser.parseSelectionString('3, 6-9');
  // => [3, 6, 7, 8, 9]

rangeSelectionParser.selectFromArray(['a', 'b', 'c', 'd', 'e'], '1-3, 5');
  // => ['a', 'b', 'c', 'e']

rangeSelectionParser.selectFromArray(['aa', 'bb', 'cc', 'dd'], '2-');
  // => ['bb', 'cc', 'dd']

Parser is very forgiving:

rangeSelectionParser.parseSelectionString(' 0 ,  5- 9 13');
  // => [0, 5, 6, 7, 8, 9, 13]

Testing

Run tests on command line with Karma

karma start

Module stats last updated: 2015-04-19 02:14:18

Disclaimer: Some data on this page may have been gathered from the authors GitHub respository. If you see any mistakes or outdated information please let us know. Thanks!