Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html ng-app="app">
<head>
  <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.min.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body ng-controller="MainCtrl as main">
  <table>
    <thead>
      <tr>
        <th>Chapter</th>
        <th>Section</th>
        <th>Words</th>
      </tr>
    </thead>
    <tbody>
      <tr class="tr-for" ng-repeat-start="chapter in main.book"></tr>
        <tr ng-repeat-start="section in chapter.sections" ng-repeat-end>
          <td>{{chapter.name}}</td>
          <td>{{section.name}}</td>
          <td>{{section.words}}</td>
        </tr>
      <tr class="tr-end" ng-repeat-end></tr>
    </tbody>
  </table>
</body>
</html>
 
BookFactory = ->
  [
    {
      name: 'Chapter 1',
      sections: [
        {
          name: '1-1',
          words: 1024
        },
        {
          name: '1-2',
          words: 512
        }
      ]
    },
    {
      name: 'Chapter 2'
      sections: [
        {
          name: '2-1',
          words: 2048
        },
        {
          name: '2-2',
          words: 256
        }
      ]
    }
  ]
MainCtrl = (BookFactory) ->
  this.hey = 'asdf'
  this.book = BookFactory
  this
  
angular
  .module('app', [])
  .controller('MainCtrl', MainCtrl)
  .factory('BookFactory', BookFactory)
Output

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers