cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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.

            
              <main ng-app="myApp">
  <p>Two way data binding can be used to display what the user types in real time:</p>
  <div>
    <label>Input:</label>
    <input type="text" id="input" />
  </div>
  <div>
    <label>Output:<label>
    <span id="output"></span>
  </div>
      
  <hr>
      
  <p>Use two way data binding to filter a list on the fly:</p>
      
  <table border="1" cellspacing="0" cellpadding="0" ng-controller="myCtrl">
    <tr>
      <td>Filter:</td>
      <td><input type="text" id="filtering"></td>
    </tr>
    
    <tr>
      <th>Name</th>
      <th>Email Address</th>
    </tr>
    
    <tbody id="people">
      
    </tbody>
  </table>
</main>
            
          
!
            
              * {
  box-sizing: border-box;
}

div {
  margin: 10px;
  padding: 5px;
  width: 320px;
}

table {
  width: 50%;
}

td {
  padding: 5px;
}

td input {
  width: 100%;
  padding: 10px;
}

            
          
!
            
              (function () {
  // Function required for data binding
  $('#input').keyup(function (event) {
    $('#output').html($('#input').val());
  });
  
  var people = [
      { name: "John Smith", email: "smithj@example.com" },
      { name: "Jane Doe", email: "jane.doe@example.com" },
      { name: "Jeff Smith", email: "jsmith@mail.com" },
      { name: "Jake Doe", email: "jake@sf.com" }
    ];
      
  // "ng-repeat" to make the array add to the table
  $.each(people, function(index, value) {
    $('#people').append("<tr><td>" + 
      value.name +
      "</td><td>" +
      value.email + "</td></tr>"
    );
  });
  
  // "filtering"
  $('#filtering').keyup(function (event) {
    var filtering = $(this).val();
    if(filtering == '') {
      $('#people tr').show();
    }
    
    // Filter the people
    $('#people').find('tr').each(function () {
      var values = [];
      $this  = $(this);
      
      // Get the value of the elements
      $this.children('td').each(function () {
        values.push($(this)[0].innerText);
      });
      
      // Show hide if value is in the tds
      $.grep(values, function (n, i) {
        if(n.indexOf(filtering) >= 0) {
          $this.show();
        } else {
          $this.hide();
        }
      }, true);
    })
  });
})();
            
          
!
999px
Loading ..................

Console