Skip to content

Instantly share code, notes, and snippets.

@raphaelfruneaux
Created August 22, 2016 18:58
Show Gist options
  • Save raphaelfruneaux/bb228e5ae90520b0bfbbaab43ce96fd4 to your computer and use it in GitHub Desktop.
Save raphaelfruneaux/bb228e5ae90520b0bfbbaab43ce96fd4 to your computer and use it in GitHub Desktop.
Angularjs range filter, n for n in [] | range:0:20
<select name="HH" data-ng-model="" style="width:auto;"
data-ng-options="n for n in [] | range:0:20" required>
<option value="">----</option>
</select>
angular.module('Filters', []).
filter('range', function () {
return function (input, min, max) {
min = parseInt(min); //Make string input int
max = parseInt(max);
for (var i = min; i < max; i++)
input.push(i.toString().padLeft(2, "0"));
return input;
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment