Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <html ng-app="contactsApp">
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">


    <link href="" rel="stylesheet">
    <script src=""></script>


  <body ng-controller="MainCtrl">
    <ion-header-bar class="bar-positive">
      <h1 class="title">3000 Contacts</h1>
      <div class="button" ng-click="scrollBottom()">
        Scroll Bottom
    <ion-header-bar class="bar-light bar-subheader">
      <input type="search"
             placeholder="Filter contacts..."
             ng-focus="searchFocused = true"
             ng-blur="searchFocused = false"
      <button ng-if="search.length"
              class="button button-icon ion-android-close input-button"
        <ion-item class="my-item"
           ng-repeat="item in getContacts()"
           id="{{ item.isLetter ? (item.letter + '_divider') : ''}}"
           ng-style="{'line-height': getItemHeight(item) + 'px'}"
           ng-class="{'item-divider': item.isLetter}">
          <img ng-if="!item.isLetter" ng-src="{{55 + ($index % 10)}}">
          {{item.letter || (item.first_name+' '+item.last_name)}}

              .button.button-icon.input-button {
  position: absolute;
  right: 0;
  top: 5px;
  color: #bbb;

.item img {
  height: 60px;
  width: 60px;
  float: left;
  margin-top: 20px;
  margin-right: 10px;

.my-item.item {
  padding-top: 0;
  padding-bottom: 0;

.full-width {
  width: 100%;

              angular.module('contactsApp', ['ionic'])
.controller('MainCtrl', function($scope, $ionicScrollDelegate, filterFilter, $location, $anchorScroll) {
  var letters = $scope.letters = [];
  var contacts = $scope.contacts = [];
  var currentCharCode = ' '.charCodeAt(0) - 1;

  //window.CONTACTS is defined below
    .sort(function(a, b) {
      return a.last_name > b.last_name ? 1 : -1;
    .forEach(function(person) {
      //Get the first letter of the last name, and if the last name changes
      //put the letter in the array
      var personCharCode = person.last_name.toUpperCase().charCodeAt(0);
      if (personCharCode < 65) {
         personCharCode = 35; 
      //We may jump two letters, be sure to put both in
      //(eg if we jump from Adam Bradley to Bob Doe, add both C and D)
      var difference = personCharCode - currentCharCode;

      for (var i = 1; i <= difference; i++) {
        addLetter(currentCharCode + i);
      currentCharCode = personCharCode;

  //If names ended before Z, add everything up to Z
  for (var i = currentCharCode + 1; i <= 'Z'.charCodeAt(0); i++) {

  function addLetter(code) {
    var letter = String.fromCharCode(code);

      isLetter: true,
      letter: letter

  //Letters are shorter, everything else is 52 pixels
  $scope.getItemHeight = function(item) {
    return item.isLetter ? 40 : 100;

  $scope.scrollTop = function() {
  $scope.scrollBottom = function() {

  var letterHasMatch = {};
  $scope.getContacts = function() {
    letterHasMatch = {};
    //Filter contacts by $
    //Additionally, filter letters so that they only show if there
    //is one or more matching contact
    return contacts.filter(function(item) {
      var itemDoesMatch = !$ || item.isLetter ||
        item.first_name.toLowerCase().indexOf($ > -1 ||
        item.last_name.toLowerCase().indexOf($ > -1;

      //Mark this person's last name letter as 'has a match'
      if (!item.isLetter && itemDoesMatch) {

        var letter = item.last_name.charAt(0).toUpperCase();
        if ( item.last_name.charCodeAt(0) < 65 ){
          letter = "#";
        letterHasMatch[letter] = true;

      return itemDoesMatch;
    }).filter(function(item) {
      //Finally, re-filter all of the letters and take out ones that don't
      //have a match
      if (item.isLetter && !letterHasMatch[item.letter]) {
        return false;
      return true;

  $scope.clearSearch = function() {
    $ = '';

window.CONTACTS = [{"id":1,"first_name":"Patrick","last_name":"Adams","country":"Cyprus","ip_address":"","email":""},
{"id":10,"first_name":"Tina","last_name":"Johnson","country":"United States Virgin Islands","ip_address":"","email":""},
{"id":13,"first_name":"Nicholas","last_name":"Marker","country":"British Indian Ocean Territory","ip_address":"","email":""},
{"id":16,"first_name":"Jessica","last_name":"Peterson","country":"Sao Tome and Principe","ip_address":"","email":""},
{"id":17,"first_name":"Willie","last_name":"Quite","country":"US Minor Outlying Islands","ip_address":"","email":""},
{"id":19,"first_name":"Arthur","last_name":"Simmons","country":"Faroe Islands","ip_address":"","email":""},
{"id":24,"first_name":"Gerald","last_name":"Veyes","country":"Isle of Man","ip_address":"","email":""},
{"id":26,"first_name":"Brandon","last_name":"Xi","country":"Vietnam","ip_address":"","email":""},{"id":27,"first_name":"Brandon","last_name":"Yore","country":"Vietnam","ip_address":"","email":""},                  {"id":28,"first_name":"Brandon","last_name":"Zeff","country":"Vietnam","ip_address":"","email":""}];

🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.