Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="//cdnjs.cloudflare.com/ajax/libs/polymer/0.2.3/platform.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/polymer/0.2.3/polymer.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
  <test-component></test-component>
</body>
</html>
<polymer-element name='test-component' attributes='itemlist filterlist'>
  <template>
    <style>
    </style>
    <table id='table'>
      <tr template repeat="{{item in itemlist | applyFilter(filterlist)}}">
        <td>test</td>
      </tr>
    </table>
    <input type='button' value='remove 1 element' on-click={{clicked}}></input>
    <div id='msg'></div>  
</template>
  <script>
    Polymer('test-component', {
      itemlist: [1,2,3],
      filterlist: [1,2,3],
      applyFilter: function(itemlist, filterlist) {
        var results = itemlist;
        if (filterlist) {
          results = itemlist.filter(function(item) {
            var test = false;
            filterlist.forEach(function(filteritem) {
              test = test || ((new RegExp(filteritem)).test(item));
            });
            return test;
          });
        }
        return results;
      },
      filterlistChanged: function() {
        this.$.table.getElementsByTagName('template')[0].iterator_.updateIteratedValue();
      },
      clicked: function() {
        this.$.msg.innerHTML = 'Filter list was ' + this.filterlist;
        this.filterlist.splice(1,1);
        this.$.msg.innerHTML += ', now it\'s ' + this.filterlist;
      }
    });
  </script>
</polymer-element>
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers