https://github.com/andrewmcgivery/ionic-ion-autoListDivider
Gives a set of directives for automatically adding in list dividers for an ng-repeat. (Works for Alphabetical or by Categories)
https://github.com/andrewmcgivery/ionic-ion-autoListDivider
Last synced: 7 months ago
JSON representation
Gives a set of directives for automatically adding in list dividers for an ng-repeat. (Works for Alphabetical or by Categories)
- Host: GitHub
- URL: https://github.com/andrewmcgivery/ionic-ion-autoListDivider
- Owner: andrewmcgivery
- Created: 2015-02-04T22:30:24.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2016-10-31T20:01:36.000Z (over 9 years ago)
- Last Synced: 2025-10-31T06:49:00.175Z (7 months ago)
- Language: JavaScript
- Size: 175 KB
- Stars: 75
- Watchers: 8
- Forks: 20
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-ionic - andrewmcgivery/ionic-ion-autoListDivider
README
# ionic-ion-autoListDivider
Gives a set of directives for automatically adding in list dividers for an ng-repeat. (Works for Alphabetical or by Categories)
# Setup
You'll need a list of objects (sorted) and an `ng-repeat`.
Import the script and include the module
```
angular.module('ionicApp', ['ionic','ionic.ion.autoListDivider'])
```
An example sorting function in your controller:
```
items.sort(function(a,b){
var textA = a.user.name.first.toUpperCase();
var textB = b.user.name.first.toUpperCase();
return (textA < textB) ? -1 : (textA > textB) ? 1 : 0;
})
```
# Basic Usage
Take any `ng-repeat` and add the `auto-list-divider` and the `auto-list-divider-value` attributes. The `auto-list-divider-value` attribute should have the property passed in that you are sorting on.
```
```
By default, it will divide these items alphabetically by the first letter of the value passed in.
# Example: Default Behavior
Default behavior is to take the first letter of the `auto-list-divider-value` passed in and use that to create alphabetical dividers.
```
```
# Example: Custom Divider Function
A custom function to calculate the divider based on the passed in value can be specified using `auto-divider-function`. This should be the name of a fucction in your controllers scope.
```
```
In your controller...
```
$scope.dividerFunction = function(key){
return key;
}
```
`key` will be the value passed into `auto-divider-value`.
CodePen of examples: http://codepen.io/andrewmcgivery/pen/XJeQyW