mardi 1 novembre 2016

How to create a table with random data in Ember.Js

I want to create a random table data but only cells makes random the rows alway repeated. Here is my code component/ember-app..js

    import Ember from 'ember';

export default Ember.Component.extend({
  willRender: function() {
    var tableRows = [];
    var value = ['|', '-'];
    var numRows = 20;
    var numCells = 20;
    for (var row = 1; row <= numRows; row++) {
      for (var cell = 1; cell <= numCells; cell++) {
        tableRows[row] = value[Math.round(Math.random())];
      }
    }

    this.set('rows', {
      'tableRows': tableRows,
    });

  }
});

And templates/components/ember-app.hbs

  <table>


  <tr>
      
      <td><button id="button_id" value=""></button></td>
      
  </tr>
  
  
</table>




Aucun commentaire:

Enregistrer un commentaire