An open API service indexing awesome lists of open source software.

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)

Awesome Lists containing this project

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