Pen Settings

HTML

CSS

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

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div ng-controller="ContactChipDemoCtrl as ctrl" layout="column" class="chipsdemoContactChips" ng-app="MyApp">

  <md-content class="md-padding autocomplete" layout="column">
    <md-contact-chips ng-model="ctrl.contacts" md-contacts="ctrl.querySearch($query)" md-contact-name="name" md-contact-image="image" md-contact-email="email" md-require-match="" filter-selected="ctrl.filterSelected" placeholder="To">
    </md-contact-chips>

    <md-list class="fixedRows">
      <md-subheader class="md-no-sticky">Contacts</md-subheader>
      <md-list-item class="md-2-line contact-item" ng-click="ctrl.selectChip(contact)" ng-repeat="(index, contact) in ctrl.allContacts" ng-if="ctrl.contacts.indexOf(contact) < 0" >
        <img ng-src="{{contact.image}}" class="md-avatar" alt="{{contact.name}}">
        <div class="md-list-item-text compact">
          <h3>{{contact.name}}</h3>
          <p>{{contact.email}}</p>
        </div>
      </md-list-item>
      <md-list-item class="md-2-line contact-item selected" ng-repeat="(index, contact) in ctrl.contacts">
        <img ng-src="{{contact.image}}" class="md-avatar" alt="{{contact.name}}">
        <div class="md-list-item-text compact">
          <h3>{{contact.name}}</h3>
          <p>{{contact.email}}</p>
        </div>
      </md-list-item>
    </md-list>

  </md-content>
</div>
              
            
!

CSS

              
                .chipsdemoContactChips md-content.autocomplete {
  min-height: 250px; }
.chipsdemoContactChips .md-item-text.compact {
  padding-top: 8px;
  padding-bottom: 8px; }
.chipsdemoContactChips .contact-item {
  box-sizing: border-box; }
  .chipsdemoContactChips .contact-item.selected {
    opacity: 0.5; }
    .chipsdemoContactChips .contact-item.selected h3 {
      opacity: 0.5; }
  .chipsdemoContactChips .contact-item .md-list-item-text {
    padding: 14px 0; }
    .chipsdemoContactChips .contact-item .md-list-item-text h3 {
      margin: 0 !important;
      padding: 0;
      line-height: 1.2em !important; }
    .chipsdemoContactChips .contact-item .md-list-item-text h3, .chipsdemoContactChips .contact-item .md-list-item-text p {
      text-overflow: ellipsis;
      white-space: nowrap;
      overflow: hidden; }
  @media (min-width: 900px) {
    .chipsdemoContactChips .contact-item {
      float: left;
      width: 33%; } }
.chipsdemoContactChips md-contact-chips {
  margin-bottom: 10px; }
.chipsdemoContactChips .md-chips {
  padding: 5px 0 8px; }
.chipsdemoContactChips .fixedRows {
  height: 250px;
  overflow: hidden; }

              
            
!

JS

              
                (function() {
  'use strict';
  angular
    .module('MyApp')
    .controller('ContactChipDemoCtrl', DemoCtrl);

  function DemoCtrl($scope, $timeout, $q) {
    var self = this;

    self.querySearch = querySearch;
    self.allContacts = loadContacts();
    self.contacts = [];
    self.filterSelected = true;
    self.selectChip = selectChip;

    /**
     * Search for contacts.
     */
    function querySearch(query) {
      var results = query ?
        self.allContacts.filter(createFilterFor(query)) : [];
      return results;
    }

    /**
     * Create filter function for a query string
     */
    function createFilterFor(query) {
      var lowercaseQuery = angular.lowercase(query);

      return function filterFn(contact) {
        return (contact._lowername.indexOf(lowercaseQuery) != -1);;
      };

    }

    function selectChip(contact) {

      $timeout(function() {
        
        self.contacts.push(contact);
        
      }, 300);

    }

    function loadContacts() {
      var contacts = [
        'Marina Augustine',
        'Oddr Sarno',
        'Nick Giannopoulos',
        'Narayana Garner',
        'Anita Gros',
        'Megan Smith',
        'Tsvetko Metzger',
        'Hector Simek',
        'Some-guy withalongalastaname'
      ];

      return contacts.map(function(c, index) {
        var cParts = c.split(' ');
        var contact = {
          name: c,
          email: cParts[0][0].toLowerCase() + '.' + cParts[1].toLowerCase() + '@example.com',
          image: 'http://lorempixel.com/50/50/people?' + index,
          selected: false
        };
        contact._lowername = contact.name.toLowerCase();
        return contact;
      });
    }
  }

})();
              
            
!
999px

Console