GithubHelp home page GithubHelp logo

johnny13 / ion-alpha-scroll Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aquint/ion-alpha-scroll

0.0 2.0 0.0 3.07 MB

Alphabetically indexed list with alpha scroll bar.

CSS 6.31% JavaScript 93.69%

ion-alpha-scroll's Introduction

ion-alpha-scroll

Configurable Ionic directive for alphabetically indexed list with an alpha scroll bar.

#Table of contents

Demo

Animated demo

Installation

  1. Use bower to install the new module:
bower install ion-alpha-scroll --save
  1. Import the ion-alpha-scroll javascript and css file into your HTML file:
<script src="bower_components/ion-alpha-scroll/dist/ion-alpha-scroll.js"></script>
<link href="bower_components/ion-alpha-scroll/dist/ion-alpha-scroll.css" rel="stylesheet">
  1. Add ion-alpha-scroll as a dependency on your Ionic app:
angular.module('myApp', [
  'ionic',
  'ion-alpha-scroll'
]);

Usage

To use the ion-alpha-scroll directive simply add the following snippet to your template:

<ion-alpha-scroll ng-model="model" key="keyName" subheader="true">
  Content Goes here...
</ion-alpha-scroll>

where 'ng-model' is the model you would like to sort and 'key' is the name of the key you would like to sort by.

The 'subheader' attribute is optional, to be set if using a subheader in the view to allow proper scroll height.

To display the properties of each item in the model, you can use the 'item' object within the directive:

	<ion-alpha-scroll ng-model="model" key="keyName">
	  <div>Name: {{item.name}}</div>
	  <div>Address: {{item.address}}</div>
	</ion-alpha-scroll>

Options for setting up a custom config.

  <ion-alpha-scroll ng-model="contacts" key="dn" filter="searchPeeps" on-refresh="doRefresh()">
    ...
  </ion-alpha-scroll>

Heres a quick example:

services.js

angular.module('example.services', [])

.factory('Contacts', function() {

  // Some fake testing data
  var contacts = [
  {
    id: 0,
    name: 'Emily Kinney',
    address: '123 Everywhere Cool St.'
    face: 'https://raw.githubusercontent.com/johnny13/ion-alpha-scroll/master/demo/emily.png'
  }, {
    id: 1,
    name: 'Max Lynx',
    address: '123 Fake St.'
    face: 'https://avatars3.githubusercontent.com/u/11214?v=3&s=460'
  },{
    id: 2,
    name: 'Adam Bradleyson',
    address: '123 Fake St.'
    face: 'https://pbs.twimg.com/profile_images/479090794058379264/84TKj_qa.jpeg'
  }, {
    id: 3,
    name: 'Perry Governor',
    address: '123 Fake St.'
    face: 'https://pbs.twimg.com/profile_images/491995398135767040/ie2Z_V6e.jpeg'
  }, {
    id: 4,
    name: 'Mike Harrington',
    address: '123 Fake St.'
    face: 'https://pbs.twimg.com/profile_images/578237281384841216/R3ae1n61.png'
  }

  ...

  ];


  return {
    all: function() {
      return contacts;
    },
    remove: function(contact) {
      contacts.splice(contacts.indexOf(contact), 1);
    },
    get: function(contactId) {
      for (var i = 0; i < contacts.length; i++) {
        if (contacts[i].id === parseInt(contactId)) {
          return contacts[i];
        }
      }
      return null;
    }
  };
});

controllers.js

angular.module('example.controllers', [])

.controller('contactsCtrl', ['$scope','Contacts',function($scope, Contacts) {
 
	$scope.contacts = Contacts.all();

)]};

contacts-list.html

<ion-view view-title="Contacts">
  <ion-content>
    <ion-alpha-scroll ng-model="contacts" key="name">
      <div>{{item.name}}</div>
      <div>{{item.description}}</div>
    </ion-alpha-scroll>
  </ion-content>
</ion-view>

Acknowledgements

Initial inspiration and code taken from this codepen by mikelucid

License

The Ionic alpha-scroll directive is available under the MIT license.

ion-alpha-scroll's People

Contributors

aquint avatar johnny13 avatar poocart avatar

Watchers

 avatar James Cloos 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.