AngularJS is a Javascript MVC framework from the fine folks over at Google. The focus of Angular is building complex HTML based client applications. Its design philosophy is data first, where your data will be updating the DOM. Contrast this to a framework like JQuery where the DOM will update your data.

AngularJS Logo

This is the fourth in a series of posts on AngularJS where we are using Chemistry data from the periodic table to help us understand the framework. The others posts are

  1. AngularJS - Introduction
  2. AngularJS - Introducing AngularJS Controllers
  3. AngularJS - Introducing NG-Repeat
  4. AngularJS - More with NG-Repeat
  5. AngularJS - Image Binding
  6. AngularJS - Introducing Templates
  7. AngularJS - Introducing Routing
  8. AngularJS - Introduction to Services
  9. AngularJS - Introduction to Directives
  10. AngularJS - Further with Directives
  11. AngularJS - Best Practices
  12. AngularJS - CSS Animations

Note: AngularJS does not allow for more than one ng-app directive. When I have multiple angular posts on the home page of my blog, only one application will work. I need to refactor the entire site to account for this. All of that to say this, you are best clicking on a single article so you can see the pages in action.

In this post, we are going to dig a bit deeper into ng-repeat and discover a few things.

To level set, we have a controller called chemistryApp.js. This creates our AngularJS application

chemistryApp.js

var chemistryApp = angular.module('chemistryApp', []);

and a controller that references are json file of chemistry data and sets it to a scope variable

chemistryController.js

chemistryApp.controller('chemCtrl',
    function chemCtrl($scope) {
        $scope.periodic = perioicData;
    }
);

First up, instead of creating an unordered list, we are going to create a table. This is done by putting the ng-repeat directive on a <tr> tag. For example

 <tr data-ng-repeat="element in periodic.elements ">

Then we can add our data on a cell by cell basis. For this example, we are going to link to a Wikipedia article about each element, and then display things like the atomic number, atomic weight, etc. Tying this with our ng-repeat directive and our table markup becomes

<table class="table table-striped table-bordered table-hover table-condensed">
            <tr>
                <th>Name</th><th>Atomic Number</th><th>Weight</th><th>Phase</th><th>Ionization Energy</th><th>Melting Point</th><th>Boiling</th>
            </tr>
            <tr data-ng-repeat="element in periodic.elements ">
                <td><a href="http://en.wikipedia.org/wiki/{{element.name}}" Title="Wikipedia article on {{element.name}}" target="_top">{{element.name}}</a></td>
                <td>{{element.atomicNumber}}</td>
                <td>{{element.atomicWeight}}</td>
                <td>{{element.phase}}</td>
                <td>{{element.ionization}}</td>
                <td>{{element.melting}}</td>
                <td>{{element.boiling}}</td>
            </tr>
        </table>

We now have a list of the Chemical elements in a table.

NameAtomic NumberWeightPhaseIonization EnergyMelting PointBoiling
Hydrogen 1 1.00794 Gas 13.5984 -259.15 -252.87
Helium 2 4.002602 Gas 24.5874 0 -268.93
Lithium 3 6.941 Solid 5.3917 180.54 1342
Beryllium 4 9.012182 Solid 9.3227 1287 2470
Boron 5 10.811 Solid 8.298 2075 4000
Carbon 6 12.0107 Solid 11.2603 3550 4027
Nitrogen 7 14.0067 Gas 14.5341 -210.1 -195.79
Oxygen 8 15.9994 Gas 13.6181 -218.3 -182.9
Fluorine 9 18.9984032 Gas 17.4228 -219.6 -188.12
Neon 10 20.1797 Gas 21.5645 -248.59 -246.08
Sodium 11 22.98977 Solid 5.1391 97.72 883
Magnesium 12 24.305 Solid 7.6462 650 1090
Aluminum 13 26.981538 Solid 5.9858 660.32 2519
Silicon 14 28.0855 Solid 8.1517 1414 2900
Phosphorus 15 30.97361 Solid 10.4867 44.2 280.5
Sulfur 16 32.065 Solid 10.36 115.21 444.72
Chlorine 17 35.453 Gas 12.9676 -101.5 -34.04
Argon 18 39.948 Gas 15.7596 -189.3 -185.8
Potassium 19 39.0983 Solid 4.3407 63.38 759
Calcium 20 40.078 Solid 6.1132 842 1484
Scandium 21 44.95591 Solid 6.5615 1541 2830
Titanium 22 47.867 Solid 6.8281 1668 3287
Vanadium 23 50.9415 Solid 6.7462 1910 3407
Chromium 24 51.9961 Solid 6.7665 1907 2671
Manganese 25 54.938049 Solid 7.434 1246 2061
Iron 26 55.845 Solid 7.9024 1538 2861
Cobalt 27 58.9332 Solid 7.881 1495 2927
Nickel 28 58.6934 Solid 7.6398 1455 2913
Copper 29 63.546 Solid 7.7264 1084.62 2927
Zinc 30 65.409 Solid 9.3942 419.53 907
Gallium 31 69.723 Solid 5.9993 29.76 2204
Germanium 32 72.64 Solid 7.8994 938.3 2820
Arsenic 33 74.9216 Solid 9.7886 817 614
Selenium 34 78.96 Solid 9.7524 221 685
Bromine 35 79.904 Liquid 11.8138 -7.3 59
Krypton 36 83.798 Gas 13.9996 -157.36 -153.22
Rubidium 37 85.4678 Solid 4.1771 39.31 688
Strontium 38 87.62 Solid 5.6949 777 1382
Yttrium 39 88.90585 Solid 6.2173 1526 3345
Zirconium 40 91.224 Solid 6.6339 1855 4409
Niobium 41 92.90638 Solid 6.7589 2477 4744
Molybdenum 42 95.94 Solid 7.0924 2623 4639
Technetium 43 98 Synthetic 7.28 2157 4265
Ruthenium 44 101.07 Solid 7.3605 2334 4150
Rhodium 45 102.9055 Solid 7.4589 1964 3695
Palladium 46 106.42 Solid 8.3369 1554.9 2963
Silver 47 107.8682 Solid 7.5762 961.78 2162
Cadmium 48 112.411 Solid 8.9938 321.07 767
Indium 49 114.818 Solid 5.7864 156.6 2072
Tin 50 118.71 Solid 7.3439 231.93 2602
Antimony 51 121.76 Solid 8.6084 630.63 1587
Tellurium 52 127.6 Solid 9.0096 449.51 988
Iodine 53 126.90447 Solid 10.4513 113.7 184.3
Xenon 54 131.293 Gas 12.1298 -111.8 -108
Cesium 55 132.90545 Solid 3.8939 28.44 671
Barium 56 137.327 Solid 5.2117 727 1870
Lanthanum 57 138.9055 Solid 5.5769 920 3464
Cerium 58 140.116 Solid 5.5387 798 3360
Praseodymium 59 140.90765 Solid 5.473 931 3290
Neodymium 60 144.24 Solid 5.525 1021 3100
Promethium 61 145 Synthetic 5.582 1100 3000
Samarium 62 150.36 Solid 5.6437 1072 1803
Europium 63 151.964 Solid 5.6704 822 1527
Gadolinium 64 157.25 Solid 6.1498 1313 3250
Terbium 65 158.92534 Solid 5.8638 1356 3230
Dysprosium 66 162.5 Solid 5.9389 1412 2567
Holmium 67 164.93032 Solid 6.0215 1474 2700
Erbium 68 167.259 Solid 6.1077 1497 2868
Thulium 69 168.93421 Solid 6.1843 1545 1950
Ytterbium 70 173.04 Solid 6.2542 819 1196
Lutetium 71 174.967 Solid 5.4259 1663 3402
Hafnium 72 178.49 Solid 6.8251 2233 4603
Tantalum 73 180.9479 Solid 7.5496 3017 5458
Tungsten 74 183.84 Solid 7.864 3422 5555
Rhenium 75 186.207 Solid 7.8335 3186 5596
Osmium 76 190.23 Solid 8.4382 3033 5012
Iridium 77 192.217 Solid 8.967 2466 4428
Platinum 78 195.078 Solid 8.9588 1768.3 3825
Gold 79 196.96655 Solid 9.2255 1064.18 2856
Mercury 80 200.59 Liquid 10.4375 -38.83 356.73
Thallium 81 204.3833 Solid 6.1082 304 1473
Lead 82 207.2 Solid 7.4167 327.46 1749
Bismuth 83 208.98038 Solid 7.2855 271.3 1564
Polonium 84 209 Solid 8.414 254 962
Radon 86 222 Gas 10.7485 -71 -61.7
Radium 88 226 Solid 5.2784 700 1737
Actinium 89 227 Solid 5.17 1050 3200
Thorium 90 232.0381 Solid 6.3067 1750 4820
Protactinium 91 231.03588 Solid 5.89 1572 4000
Uranium 92 238.02891 Solid 6.1941 1135 3927
Neptunium 93 237 Synthetic 6.2657 644 4000
Plutonium 94 244 Synthetic 6.026 640 3230
Americium 95 243 Synthetic 5.9738 1176 2011
Curium 96 247 Synthetic 5.9914 1345 3110

We can also, just like in our previous example, bind a filter to an input box and search for a chemical element by name and have it filter the list automatically.

   <div id="periodicTable"  data-ng-controller="chemCtrl" >
        <input type="text" data-ng-model="elementNameOnlyTable"/>
        <table class="table table-striped table-bordered table-hover table-condensed">
            <tr>
                <th>Name</th><th>Atomic Number</th><th>Weight</th><th>Phase</th><th>Ionization Energy</th><th>Melting Point</th><th>Boiling</th>
            </tr>
            <tr data-ng-repeat="element in periodic.elements | filter:{name:elementNameOnlyTable}">
                <td><a href="http://en.wikipedia.org/wiki/" Title="Wikipedia article on " target="_top"></a></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
            </tr>
        </table>
    </div>
NameAtomic NumberWeightPhaseIonization EnergyMelting PointBoiling
Hydrogen 1 1.00794 Gas 13.5984 -259.15 -252.87
Helium 2 4.002602 Gas 24.5874 0 -268.93
Lithium 3 6.941 Solid 5.3917 180.54 1342
Beryllium 4 9.012182 Solid 9.3227 1287 2470
Boron 5 10.811 Solid 8.298 2075 4000
Carbon 6 12.0107 Solid 11.2603 3550 4027
Nitrogen 7 14.0067 Gas 14.5341 -210.1 -195.79
Oxygen 8 15.9994 Gas 13.6181 -218.3 -182.9
Fluorine 9 18.9984032 Gas 17.4228 -219.6 -188.12
Neon 10 20.1797 Gas 21.5645 -248.59 -246.08
Sodium 11 22.98977 Solid 5.1391 97.72 883
Magnesium 12 24.305 Solid 7.6462 650 1090
Aluminum 13 26.981538 Solid 5.9858 660.32 2519
Silicon 14 28.0855 Solid 8.1517 1414 2900
Phosphorus 15 30.97361 Solid 10.4867 44.2 280.5
Sulfur 16 32.065 Solid 10.36 115.21 444.72
Chlorine 17 35.453 Gas 12.9676 -101.5 -34.04
Argon 18 39.948 Gas 15.7596 -189.3 -185.8
Potassium 19 39.0983 Solid 4.3407 63.38 759
Calcium 20 40.078 Solid 6.1132 842 1484
Scandium 21 44.95591 Solid 6.5615 1541 2830
Titanium 22 47.867 Solid 6.8281 1668 3287
Vanadium 23 50.9415 Solid 6.7462 1910 3407
Chromium 24 51.9961 Solid 6.7665 1907 2671
Manganese 25 54.938049 Solid 7.434 1246 2061
Iron 26 55.845 Solid 7.9024 1538 2861
Cobalt 27 58.9332 Solid 7.881 1495 2927
Nickel 28 58.6934 Solid 7.6398 1455 2913
Copper 29 63.546 Solid 7.7264 1084.62 2927
Zinc 30 65.409 Solid 9.3942 419.53 907
Gallium 31 69.723 Solid 5.9993 29.76 2204
Germanium 32 72.64 Solid 7.8994 938.3 2820
Arsenic 33 74.9216 Solid 9.7886 817 614
Selenium 34 78.96 Solid 9.7524 221 685
Bromine 35 79.904 Liquid 11.8138 -7.3 59
Krypton 36 83.798 Gas 13.9996 -157.36 -153.22
Rubidium 37 85.4678 Solid 4.1771 39.31 688
Strontium 38 87.62 Solid 5.6949 777 1382
Yttrium 39 88.90585 Solid 6.2173 1526 3345
Zirconium 40 91.224 Solid 6.6339 1855 4409
Niobium 41 92.90638 Solid 6.7589 2477 4744
Molybdenum 42 95.94 Solid 7.0924 2623 4639
Technetium 43 98 Synthetic 7.28 2157 4265
Ruthenium 44 101.07 Solid 7.3605 2334 4150
Rhodium 45 102.9055 Solid 7.4589 1964 3695
Palladium 46 106.42 Solid 8.3369 1554.9 2963
Silver 47 107.8682 Solid 7.5762 961.78 2162
Cadmium 48 112.411 Solid 8.9938 321.07 767
Indium 49 114.818 Solid 5.7864 156.6 2072
Tin 50 118.71 Solid 7.3439 231.93 2602
Antimony 51 121.76 Solid 8.6084 630.63 1587
Tellurium 52 127.6 Solid 9.0096 449.51 988
Iodine 53 126.90447 Solid 10.4513 113.7 184.3
Xenon 54 131.293 Gas 12.1298 -111.8 -108
Cesium 55 132.90545 Solid 3.8939 28.44 671
Barium 56 137.327 Solid 5.2117 727 1870
Lanthanum 57 138.9055 Solid 5.5769 920 3464
Cerium 58 140.116 Solid 5.5387 798 3360
Praseodymium 59 140.90765 Solid 5.473 931 3290
Neodymium 60 144.24 Solid 5.525 1021 3100
Promethium 61 145 Synthetic 5.582 1100 3000
Samarium 62 150.36 Solid 5.6437 1072 1803
Europium 63 151.964 Solid 5.6704 822 1527
Gadolinium 64 157.25 Solid 6.1498 1313 3250
Terbium 65 158.92534 Solid 5.8638 1356 3230
Dysprosium 66 162.5 Solid 5.9389 1412 2567
Holmium 67 164.93032 Solid 6.0215 1474 2700
Erbium 68 167.259 Solid 6.1077 1497 2868
Thulium 69 168.93421 Solid 6.1843 1545 1950
Ytterbium 70 173.04 Solid 6.2542 819 1196
Lutetium 71 174.967 Solid 5.4259 1663 3402
Hafnium 72 178.49 Solid 6.8251 2233 4603
Tantalum 73 180.9479 Solid 7.5496 3017 5458
Tungsten 74 183.84 Solid 7.864 3422 5555
Rhenium 75 186.207 Solid 7.8335 3186 5596
Osmium 76 190.23 Solid 8.4382 3033 5012
Iridium 77 192.217 Solid 8.967 2466 4428
Platinum 78 195.078 Solid 8.9588 1768.3 3825
Gold 79 196.96655 Solid 9.2255 1064.18 2856
Mercury 80 200.59 Liquid 10.4375 -38.83 356.73
Thallium 81 204.3833 Solid 6.1082 304 1473
Lead 82 207.2 Solid 7.4167 327.46 1749
Bismuth 83 208.98038 Solid 7.2855 271.3 1564
Polonium 84 209 Solid 8.414 254 962
Radon 86 222 Gas 10.7485 -71 -61.7
Radium 88 226 Solid 5.2784 700 1737
Actinium 89 227 Solid 5.17 1050 3200
Thorium 90 232.0381 Solid 6.3067 1750 4820
Protactinium 91 231.03588 Solid 5.89 1572 4000
Uranium 92 238.02891 Solid 6.1941 1135 3927
Neptunium 93 237 Synthetic 6.2657 644 4000
Plutonium 94 244 Synthetic 6.026 640 3230
Americium 95 243 Synthetic 5.9738 1176 2011
Curium 96 247 Synthetic 5.9914 1345 3110

The ng-repeat also has some intrinsic variable definitions. One is $index which is the current key of the element of the loop you are on.

Name$IndexAtomic NumberWeightPhaseIonization EnergyMelting PointBoiling
Hydrogen 0 1 1.00794 Gas 13.5984 -259.15 -252.87
Helium 1 2 4.002602 Gas 24.5874 0 -268.93
Lithium 2 3 6.941 Solid 5.3917 180.54 1342
Beryllium 3 4 9.012182 Solid 9.3227 1287 2470
Boron 4 5 10.811 Solid 8.298 2075 4000
Carbon 5 6 12.0107 Solid 11.2603 3550 4027
Nitrogen 6 7 14.0067 Gas 14.5341 -210.1 -195.79
Oxygen 7 8 15.9994 Gas 13.6181 -218.3 -182.9
Fluorine 8 9 18.9984032 Gas 17.4228 -219.6 -188.12
Neon 9 10 20.1797 Gas 21.5645 -248.59 -246.08
Sodium 10 11 22.98977 Solid 5.1391 97.72 883
Magnesium 11 12 24.305 Solid 7.6462 650 1090
Aluminum 12 13 26.981538 Solid 5.9858 660.32 2519
Silicon 13 14 28.0855 Solid 8.1517 1414 2900
Phosphorus 14 15 30.97361 Solid 10.4867 44.2 280.5
Sulfur 15 16 32.065 Solid 10.36 115.21 444.72
Chlorine 16 17 35.453 Gas 12.9676 -101.5 -34.04
Argon 17 18 39.948 Gas 15.7596 -189.3 -185.8
Potassium 18 19 39.0983 Solid 4.3407 63.38 759
Calcium 19 20 40.078 Solid 6.1132 842 1484
Scandium 20 21 44.95591 Solid 6.5615 1541 2830
Titanium 21 22 47.867 Solid 6.8281 1668 3287
Vanadium 22 23 50.9415 Solid 6.7462 1910 3407
Chromium 23 24 51.9961 Solid 6.7665 1907 2671
Manganese 24 25 54.938049 Solid 7.434 1246 2061
Iron 25 26 55.845 Solid 7.9024 1538 2861
Cobalt 26 27 58.9332 Solid 7.881 1495 2927
Nickel 27 28 58.6934 Solid 7.6398 1455 2913
Copper 28 29 63.546 Solid 7.7264 1084.62 2927
Zinc 29 30 65.409 Solid 9.3942 419.53 907
Gallium 30 31 69.723 Solid 5.9993 29.76 2204
Germanium 31 32 72.64 Solid 7.8994 938.3 2820
Arsenic 32 33 74.9216 Solid 9.7886 817 614
Selenium 33 34 78.96 Solid 9.7524 221 685
Bromine 34 35 79.904 Liquid 11.8138 -7.3 59
Krypton 35 36 83.798 Gas 13.9996 -157.36 -153.22
Rubidium 36 37 85.4678 Solid 4.1771 39.31 688
Strontium 37 38 87.62 Solid 5.6949 777 1382
Yttrium 38 39 88.90585 Solid 6.2173 1526 3345
Zirconium 39 40 91.224 Solid 6.6339 1855 4409
Niobium 40 41 92.90638 Solid 6.7589 2477 4744
Molybdenum 41 42 95.94 Solid 7.0924 2623 4639
Technetium 42 43 98 Synthetic 7.28 2157 4265
Ruthenium 43 44 101.07 Solid 7.3605 2334 4150
Rhodium 44 45 102.9055 Solid 7.4589 1964 3695
Palladium 45 46 106.42 Solid 8.3369 1554.9 2963
Silver 46 47 107.8682 Solid 7.5762 961.78 2162
Cadmium 47 48 112.411 Solid 8.9938 321.07 767
Indium 48 49 114.818 Solid 5.7864 156.6 2072
Tin 49 50 118.71 Solid 7.3439 231.93 2602
Antimony 50 51 121.76 Solid 8.6084 630.63 1587
Tellurium 51 52 127.6 Solid 9.0096 449.51 988
Iodine 52 53 126.90447 Solid 10.4513 113.7 184.3
Xenon 53 54 131.293 Gas 12.1298 -111.8 -108
Cesium 54 55 132.90545 Solid 3.8939 28.44 671
Barium 55 56 137.327 Solid 5.2117 727 1870
Lanthanum 56 57 138.9055 Solid 5.5769 920 3464
Cerium 57 58 140.116 Solid 5.5387 798 3360
Praseodymium 58 59 140.90765 Solid 5.473 931 3290
Neodymium 59 60 144.24 Solid 5.525 1021 3100
Promethium 60 61 145 Synthetic 5.582 1100 3000
Samarium 61 62 150.36 Solid 5.6437 1072 1803
Europium 62 63 151.964 Solid 5.6704 822 1527
Gadolinium 63 64 157.25 Solid 6.1498 1313 3250
Terbium 64 65 158.92534 Solid 5.8638 1356 3230
Dysprosium 65 66 162.5 Solid 5.9389 1412 2567
Holmium 66 67 164.93032 Solid 6.0215 1474 2700
Erbium 67 68 167.259 Solid 6.1077 1497 2868
Thulium 68 69 168.93421 Solid 6.1843 1545 1950
Ytterbium 69 70 173.04 Solid 6.2542 819 1196
Lutetium 70 71 174.967 Solid 5.4259 1663 3402
Hafnium 71 72 178.49 Solid 6.8251 2233 4603
Tantalum 72 73 180.9479 Solid 7.5496 3017 5458
Tungsten 73 74 183.84 Solid 7.864 3422 5555
Rhenium 74 75 186.207 Solid 7.8335 3186 5596
Osmium 75 76 190.23 Solid 8.4382 3033 5012
Iridium 76 77 192.217 Solid 8.967 2466 4428
Platinum 77 78 195.078 Solid 8.9588 1768.3 3825
Gold 78 79 196.96655 Solid 9.2255 1064.18 2856
Mercury 79 80 200.59 Liquid 10.4375 -38.83 356.73
Thallium 80 81 204.3833 Solid 6.1082 304 1473
Lead 81 82 207.2 Solid 7.4167 327.46 1749
Bismuth 82 83 208.98038 Solid 7.2855 271.3 1564
Polonium 83 84 209 Solid 8.414 254 962
Radon 84 86 222 Gas 10.7485 -71 -61.7
Radium 85 88 226 Solid 5.2784 700 1737
Actinium 86 89 227 Solid 5.17 1050 3200
Thorium 87 90 232.0381 Solid 6.3067 1750 4820
Protactinium 88 91 231.03588 Solid 5.89 1572 4000
Uranium 89 92 238.02891 Solid 6.1941 1135 3927
Neptunium 90 93 237 Synthetic 6.2657 644 4000
Plutonium 91 94 244 Synthetic 6.026 640 3230
Americium 92 95 243 Synthetic 5.9738 1176 2011
Curium 93 96 247 Synthetic 5.9914 1345 3110

It is interesting to note that the index is for the values you are filtering on too. So if you were to type Aluminum you will see it becomes the zero element, instead of Hydrogen.

Angular also has directives like ng-hide, ng-show and ng-class along with a plethora of other attributes.

We can use these in conjunctions with $index. This is really the key step along the journey in thinking the "Angular way". You don't want to update the dom via javascript, but use Angular to control what is displayed on your page. As an example of this, let's say we want to hide every other element in the list. We could do something like

 <tr data-ng-repeat="element in periodic.elements" data-ng-hide="$index%2">
NameAtomic NumberWeightPhaseIonization EnergyMelting PointBoiling
Hydrogen 1 1.00794 Gas 13.5984 -259.15 -252.87
Helium 2 4.002602 Gas 24.5874 0 -268.93
Lithium 3 6.941 Solid 5.3917 180.54 1342
Beryllium 4 9.012182 Solid 9.3227 1287 2470
Boron 5 10.811 Solid 8.298 2075 4000
Carbon 6 12.0107 Solid 11.2603 3550 4027
Nitrogen 7 14.0067 Gas 14.5341 -210.1 -195.79
Oxygen 8 15.9994 Gas 13.6181 -218.3 -182.9
Fluorine 9 18.9984032 Gas 17.4228 -219.6 -188.12
Neon 10 20.1797 Gas 21.5645 -248.59 -246.08
Sodium 11 22.98977 Solid 5.1391 97.72 883
Magnesium 12 24.305 Solid 7.6462 650 1090
Aluminum 13 26.981538 Solid 5.9858 660.32 2519
Silicon 14 28.0855 Solid 8.1517 1414 2900
Phosphorus 15 30.97361 Solid 10.4867 44.2 280.5
Sulfur 16 32.065 Solid 10.36 115.21 444.72
Chlorine 17 35.453 Gas 12.9676 -101.5 -34.04
Argon 18 39.948 Gas 15.7596 -189.3 -185.8
Potassium 19 39.0983 Solid 4.3407 63.38 759
Calcium 20 40.078 Solid 6.1132 842 1484
Scandium 21 44.95591 Solid 6.5615 1541 2830
Titanium 22 47.867 Solid 6.8281 1668 3287
Vanadium 23 50.9415 Solid 6.7462 1910 3407
Chromium 24 51.9961 Solid 6.7665 1907 2671
Manganese 25 54.938049 Solid 7.434 1246 2061
Iron 26 55.845 Solid 7.9024 1538 2861
Cobalt 27 58.9332 Solid 7.881 1495 2927
Nickel 28 58.6934 Solid 7.6398 1455 2913
Copper 29 63.546 Solid 7.7264 1084.62 2927
Zinc 30 65.409 Solid 9.3942 419.53 907
Gallium 31 69.723 Solid 5.9993 29.76 2204
Germanium 32 72.64 Solid 7.8994 938.3 2820
Arsenic 33 74.9216 Solid 9.7886 817 614
Selenium 34 78.96 Solid 9.7524 221 685
Bromine 35 79.904 Liquid 11.8138 -7.3 59
Krypton 36 83.798 Gas 13.9996 -157.36 -153.22
Rubidium 37 85.4678 Solid 4.1771 39.31 688
Strontium 38 87.62 Solid 5.6949 777 1382
Yttrium 39 88.90585 Solid 6.2173 1526 3345
Zirconium 40 91.224 Solid 6.6339 1855 4409
Niobium 41 92.90638 Solid 6.7589 2477 4744
Molybdenum 42 95.94 Solid 7.0924 2623 4639
Technetium 43 98 Synthetic 7.28 2157 4265
Ruthenium 44 101.07 Solid 7.3605 2334 4150
Rhodium 45 102.9055 Solid 7.4589 1964 3695
Palladium 46 106.42 Solid 8.3369 1554.9 2963
Silver 47 107.8682 Solid 7.5762 961.78 2162
Cadmium 48 112.411 Solid 8.9938 321.07 767
Indium 49 114.818 Solid 5.7864 156.6 2072
Tin 50 118.71 Solid 7.3439 231.93 2602
Antimony 51 121.76 Solid 8.6084 630.63 1587
Tellurium 52 127.6 Solid 9.0096 449.51 988
Iodine 53 126.90447 Solid 10.4513 113.7 184.3
Xenon 54 131.293 Gas 12.1298 -111.8 -108
Cesium 55 132.90545 Solid 3.8939 28.44 671
Barium 56 137.327 Solid 5.2117 727 1870
Lanthanum 57 138.9055 Solid 5.5769 920 3464
Cerium 58 140.116 Solid 5.5387 798 3360
Praseodymium 59 140.90765 Solid 5.473 931 3290
Neodymium 60 144.24 Solid 5.525 1021 3100
Promethium 61 145 Synthetic 5.582 1100 3000
Samarium 62 150.36 Solid 5.6437 1072 1803
Europium 63 151.964 Solid 5.6704 822 1527
Gadolinium 64 157.25 Solid 6.1498 1313 3250
Terbium 65 158.92534 Solid 5.8638 1356 3230
Dysprosium 66 162.5 Solid 5.9389 1412 2567
Holmium 67 164.93032 Solid 6.0215 1474 2700
Erbium 68 167.259 Solid 6.1077 1497 2868
Thulium 69 168.93421 Solid 6.1843 1545 1950
Ytterbium 70 173.04 Solid 6.2542 819 1196
Lutetium 71 174.967 Solid 5.4259 1663 3402
Hafnium 72 178.49 Solid 6.8251 2233 4603
Tantalum 73 180.9479 Solid 7.5496 3017 5458
Tungsten 74 183.84 Solid 7.864 3422 5555
Rhenium 75 186.207 Solid 7.8335 3186 5596
Osmium 76 190.23 Solid 8.4382 3033 5012
Iridium 77 192.217 Solid 8.967 2466 4428
Platinum 78 195.078 Solid 8.9588 1768.3 3825
Gold 79 196.96655 Solid 9.2255 1064.18 2856
Mercury 80 200.59 Liquid 10.4375 -38.83 356.73
Thallium 81 204.3833 Solid 6.1082 304 1473
Lead 82 207.2 Solid 7.4167 327.46 1749
Bismuth 83 208.98038 Solid 7.2855 271.3 1564
Polonium 84 209 Solid 8.414 254 962
Radon 86 222 Gas 10.7485 -71 -61.7
Radium 88 226 Solid 5.2784 700 1737
Actinium 89 227 Solid 5.17 1050 3200
Thorium 90 232.0381 Solid 6.3067 1750 4820
Protactinium 91 231.03588 Solid 5.89 1572 4000
Uranium 92 238.02891 Solid 6.1941 1135 3927
Neptunium 93 237 Synthetic 6.2657 644 4000
Plutonium 94 244 Synthetic 6.026 640 3230
Americium 95 243 Synthetic 5.9738 1176 2011
Curium 96 247 Synthetic 5.9914 1345 3110

We can also perform some Crimes Against web design. For example, nothing is uglier than wrapping your table in Green Bay Packer colors of Green and Gold. So I can add CSS elements like

<style>
        .tableOdd {
            background-color: green;
        }
        .tableEven {
            background-color: gold;
        }
    </style>

Then we can use the ng-class on the <tr> we are binding to in order to make even/odd rows change colors.

<tr data-ng-repeat="element in periodic.elements" data-ng-class="{tableEven: !($index%2), tableOdd: ($index%2)}">

It doesn't look pretty, and there are MUCH better ways to do this, but it gives you an example of how to think the "Angular way"

NameAtomic NumberWeightPhaseIonization EnergyMelting PointBoiling
Hydrogen 1 1.00794 Gas 13.5984 -259.15 -252.87
Helium 2 4.002602 Gas 24.5874 0 -268.93
Lithium 3 6.941 Solid 5.3917 180.54 1342
Beryllium 4 9.012182 Solid 9.3227 1287 2470
Boron 5 10.811 Solid 8.298 2075 4000
Carbon 6 12.0107 Solid 11.2603 3550 4027
Nitrogen 7 14.0067 Gas 14.5341 -210.1 -195.79
Oxygen 8 15.9994 Gas 13.6181 -218.3 -182.9
Fluorine 9 18.9984032 Gas 17.4228 -219.6 -188.12
Neon 10 20.1797 Gas 21.5645 -248.59 -246.08
Sodium 11 22.98977 Solid 5.1391 97.72 883
Magnesium 12 24.305 Solid 7.6462 650 1090
Aluminum 13 26.981538 Solid 5.9858 660.32 2519
Silicon 14 28.0855 Solid 8.1517 1414 2900
Phosphorus 15 30.97361 Solid 10.4867 44.2 280.5
Sulfur 16 32.065 Solid 10.36 115.21 444.72
Chlorine 17 35.453 Gas 12.9676 -101.5 -34.04
Argon 18 39.948 Gas 15.7596 -189.3 -185.8
Potassium 19 39.0983 Solid 4.3407 63.38 759
Calcium 20 40.078 Solid 6.1132 842 1484
Scandium 21 44.95591 Solid 6.5615 1541 2830
Titanium 22 47.867 Solid 6.8281 1668 3287
Vanadium 23 50.9415 Solid 6.7462 1910 3407
Chromium 24 51.9961 Solid 6.7665 1907 2671
Manganese 25 54.938049 Solid 7.434 1246 2061
Iron 26 55.845 Solid 7.9024 1538 2861
Cobalt 27 58.9332 Solid 7.881 1495 2927
Nickel 28 58.6934 Solid 7.6398 1455 2913
Copper 29 63.546 Solid 7.7264 1084.62 2927
Zinc 30 65.409 Solid 9.3942 419.53 907
Gallium 31 69.723 Solid 5.9993 29.76 2204
Germanium 32 72.64 Solid 7.8994 938.3 2820
Arsenic 33 74.9216 Solid 9.7886 817 614
Selenium 34 78.96 Solid 9.7524 221 685
Bromine 35 79.904 Liquid 11.8138 -7.3 59
Krypton 36 83.798 Gas 13.9996 -157.36 -153.22
Rubidium 37 85.4678 Solid 4.1771 39.31 688
Strontium 38 87.62 Solid 5.6949 777 1382
Yttrium 39 88.90585 Solid 6.2173 1526 3345
Zirconium 40 91.224 Solid 6.6339 1855 4409
Niobium 41 92.90638 Solid 6.7589 2477 4744
Molybdenum 42 95.94 Solid 7.0924 2623 4639
Technetium 43 98 Synthetic 7.28 2157 4265
Ruthenium 44 101.07 Solid 7.3605 2334 4150
Rhodium 45 102.9055 Solid 7.4589 1964 3695
Palladium 46 106.42 Solid 8.3369 1554.9 2963
Silver 47 107.8682 Solid 7.5762 961.78 2162
Cadmium 48 112.411 Solid 8.9938 321.07 767
Indium 49 114.818 Solid 5.7864 156.6 2072
Tin 50 118.71 Solid 7.3439 231.93 2602
Antimony 51 121.76 Solid 8.6084 630.63 1587
Tellurium 52 127.6 Solid 9.0096 449.51 988
Iodine 53 126.90447 Solid 10.4513 113.7 184.3
Xenon 54 131.293 Gas 12.1298 -111.8 -108
Cesium 55 132.90545 Solid 3.8939 28.44 671
Barium 56 137.327 Solid 5.2117 727 1870
Lanthanum 57 138.9055 Solid 5.5769 920 3464
Cerium 58 140.116 Solid 5.5387 798 3360
Praseodymium 59 140.90765 Solid 5.473 931 3290
Neodymium 60 144.24 Solid 5.525 1021 3100
Promethium 61 145 Synthetic 5.582 1100 3000
Samarium 62 150.36 Solid 5.6437 1072 1803
Europium 63 151.964 Solid 5.6704 822 1527
Gadolinium 64 157.25 Solid 6.1498 1313 3250
Terbium 65 158.92534 Solid 5.8638 1356 3230
Dysprosium 66 162.5 Solid 5.9389 1412 2567
Holmium 67 164.93032 Solid 6.0215 1474 2700
Erbium 68 167.259 Solid 6.1077 1497 2868
Thulium 69 168.93421 Solid 6.1843 1545 1950
Ytterbium 70 173.04 Solid 6.2542 819 1196
Lutetium 71 174.967 Solid 5.4259 1663 3402
Hafnium 72 178.49 Solid 6.8251 2233 4603
Tantalum 73 180.9479 Solid 7.5496 3017 5458
Tungsten 74 183.84 Solid 7.864 3422 5555
Rhenium 75 186.207 Solid 7.8335 3186 5596
Osmium 76 190.23 Solid 8.4382 3033 5012
Iridium 77 192.217 Solid 8.967 2466 4428
Platinum 78 195.078 Solid 8.9588 1768.3 3825
Gold 79 196.96655 Solid 9.2255 1064.18 2856
Mercury 80 200.59 Liquid 10.4375 -38.83 356.73
Thallium 81 204.3833 Solid 6.1082 304 1473
Lead 82 207.2 Solid 7.4167 327.46 1749
Bismuth 83 208.98038 Solid 7.2855 271.3 1564
Polonium 84 209 Solid 8.414 254 962
Radon 86 222 Gas 10.7485 -71 -61.7
Radium 88 226 Solid 5.2784 700 1737
Actinium 89 227 Solid 5.17 1050 3200
Thorium 90 232.0381 Solid 6.3067 1750 4820
Protactinium 91 231.03588 Solid 5.89 1572 4000
Uranium 92 238.02891 Solid 6.1941 1135 3927
Neptunium 93 237 Synthetic 6.2657 644 4000
Plutonium 94 244 Synthetic 6.026 640 3230
Americium 95 243 Synthetic 5.9738 1176 2011
Curium 96 247 Synthetic 5.9914 1345 3110

Last, we can also do fun things like sort by using select lists to quickly filter data. For example, we create a dropdown list for both the element phase

 <select data-ng-model="elementPhase">
            <option value="">All</option>
            <option value="Gas">Gas</option>
            <option value="Solid">Solid</option>
            <option value="Liquid">Liquid</option>
            <option value="Synthetic">Synthetic</option>
        </select>

and an ordering criteria

<select data-ng-model="elementOrder">
            <option value="name" selected>Name (ascending)</option>
            <option value="-name">Name (descending)</option>
            <option value="melting">Melting Point (asc)</option>
            <option value="-melting">Melting Point (desc)</option>
        </select>

We can then use the ng-filter and ng-order directives to filter and sort our table. Further, we can combine with our text box for searching by name and chain them together.

 <tr data-ng-repeat="element in periodic.elements | filter:{name:elementName} | filter:{phase:elementPhase} | orderBy:elementOrder">

Ultimately, our HTML looks like

<div id="periodicTable5"  data-ng-controller="chemCtrl" >
        Element Name:<input type="text" data-ng-model="elementName"/>
        &nbsp;State:
        <select data-ng-model="elementPhase">
            <option value="">All</option>
            <option value="Gas">Gas</option>
            <option value="Solid">Solid</option>
            <option value="Liquid">Liquid</option>
            <option value="Synthetic">Synthetic</option>
        </select>
        &nbsp;Order:
        <select data-ng-model="elementOrder">
            <option value="name" selected>Name (ascending)</option>
            <option value="-name">Name (descending)</option>
            <option value="melting">Melting Point (asc)</option>
            <option value="-melting">Melting Point (desc)</option>
        </select>

        <table class="table ">
            <tr>
                <th>Name</th><th>Atomic Number</th><th>Weight</th><th>Phase</th><th>Ionization Energy</th><th>Melting Point</th><th>Boiling</th>
            </tr>
            <tr data-ng-repeat="element in periodic.elements | filter:{name:elementName} | filter:{phase:elementPhase} | orderBy:elementOrder">
            <td><a href="http://en.wikipedia.org/wiki/" Title="Wikipedia article on " target="_top"></a></td>
                <td></td>
                <td ></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
            </tr>
        </table>
    </div>
Element Name:  State:  Order:
NameAtomic NumberWeightPhaseIonization EnergyMelting PointBoiling
Hydrogen 1 1.00794 Gas 13.5984 -259.15 -252.87
Helium 2 4.002602 Gas 24.5874 0 -268.93
Lithium 3 6.941 Solid 5.3917 180.54 1342
Beryllium 4 9.012182 Solid 9.3227 1287 2470
Boron 5 10.811 Solid 8.298 2075 4000
Carbon 6 12.0107 Solid 11.2603 3550 4027
Nitrogen 7 14.0067 Gas 14.5341 -210.1 -195.79
Oxygen 8 15.9994 Gas 13.6181 -218.3 -182.9
Fluorine 9 18.9984032 Gas 17.4228 -219.6 -188.12
Neon 10 20.1797 Gas 21.5645 -248.59 -246.08
Sodium 11 22.98977 Solid 5.1391 97.72 883
Magnesium 12 24.305 Solid 7.6462 650 1090
Aluminum 13 26.981538 Solid 5.9858 660.32 2519
Silicon 14 28.0855 Solid 8.1517 1414 2900
Phosphorus 15 30.97361 Solid 10.4867 44.2 280.5
Sulfur 16 32.065 Solid 10.36 115.21 444.72
Chlorine 17 35.453 Gas 12.9676 -101.5 -34.04
Argon 18 39.948 Gas 15.7596 -189.3 -185.8
Potassium 19 39.0983 Solid 4.3407 63.38 759
Calcium 20 40.078 Solid 6.1132 842 1484
Scandium 21 44.95591 Solid 6.5615 1541 2830
Titanium 22 47.867 Solid 6.8281 1668 3287
Vanadium 23 50.9415 Solid 6.7462 1910 3407
Chromium 24 51.9961 Solid 6.7665 1907 2671
Manganese 25 54.938049 Solid 7.434 1246 2061
Iron 26 55.845 Solid 7.9024 1538 2861
Cobalt 27 58.9332 Solid 7.881 1495 2927
Nickel 28 58.6934 Solid 7.6398 1455 2913
Copper 29 63.546 Solid 7.7264 1084.62 2927
Zinc 30 65.409 Solid 9.3942 419.53 907
Gallium 31 69.723 Solid 5.9993 29.76 2204
Germanium 32 72.64 Solid 7.8994 938.3 2820
Arsenic 33 74.9216 Solid 9.7886 817 614
Selenium 34 78.96 Solid 9.7524 221 685
Bromine 35 79.904 Liquid 11.8138 -7.3 59
Krypton 36 83.798 Gas 13.9996 -157.36 -153.22
Rubidium 37 85.4678 Solid 4.1771 39.31 688
Strontium 38 87.62 Solid 5.6949 777 1382
Yttrium 39 88.90585 Solid 6.2173 1526 3345
Zirconium 40 91.224 Solid 6.6339 1855 4409
Niobium 41 92.90638 Solid 6.7589 2477 4744
Molybdenum 42 95.94 Solid 7.0924 2623 4639
Technetium 43 98 Synthetic 7.28 2157 4265
Ruthenium 44 101.07 Solid 7.3605 2334 4150
Rhodium 45 102.9055 Solid 7.4589 1964 3695
Palladium 46 106.42 Solid 8.3369 1554.9 2963
Silver 47 107.8682 Solid 7.5762 961.78 2162
Cadmium 48 112.411 Solid 8.9938 321.07 767
Indium 49 114.818 Solid 5.7864 156.6 2072
Tin 50 118.71 Solid 7.3439 231.93 2602
Antimony 51 121.76 Solid 8.6084 630.63 1587
Tellurium 52 127.6 Solid 9.0096 449.51 988
Iodine 53 126.90447 Solid 10.4513 113.7 184.3
Xenon 54 131.293 Gas 12.1298 -111.8 -108
Cesium 55 132.90545 Solid 3.8939 28.44 671
Barium 56 137.327 Solid 5.2117 727 1870
Lanthanum 57 138.9055 Solid 5.5769 920 3464
Cerium 58 140.116 Solid 5.5387 798 3360
Praseodymium 59 140.90765 Solid 5.473 931 3290
Neodymium 60 144.24 Solid 5.525 1021 3100
Promethium 61 145 Synthetic 5.582 1100 3000
Samarium 62 150.36 Solid 5.6437 1072 1803
Europium 63 151.964 Solid 5.6704 822 1527
Gadolinium 64 157.25 Solid 6.1498 1313 3250
Terbium 65 158.92534 Solid 5.8638 1356 3230
Dysprosium 66 162.5 Solid 5.9389 1412 2567
Holmium 67 164.93032 Solid 6.0215 1474 2700
Erbium 68 167.259 Solid 6.1077 1497 2868
Thulium 69 168.93421 Solid 6.1843 1545 1950
Ytterbium 70 173.04 Solid 6.2542 819 1196
Lutetium 71 174.967 Solid 5.4259 1663 3402
Hafnium 72 178.49 Solid 6.8251 2233 4603
Tantalum 73 180.9479 Solid 7.5496 3017 5458
Tungsten 74 183.84 Solid 7.864 3422 5555
Rhenium 75 186.207 Solid 7.8335 3186 5596
Osmium 76 190.23 Solid 8.4382 3033 5012
Iridium 77 192.217 Solid 8.967 2466 4428
Platinum 78 195.078 Solid 8.9588 1768.3 3825
Gold 79 196.96655 Solid 9.2255 1064.18 2856
Mercury 80 200.59 Liquid 10.4375 -38.83 356.73
Thallium 81 204.3833 Solid 6.1082 304 1473
Lead 82 207.2 Solid 7.4167 327.46 1749
Bismuth 83 208.98038 Solid 7.2855 271.3 1564
Polonium 84 209 Solid 8.414 254 962
Radon 86 222 Gas 10.7485 -71 -61.7
Radium 88 226 Solid 5.2784 700 1737
Actinium 89 227 Solid 5.17 1050 3200
Thorium 90 232.0381 Solid 6.3067 1750 4820
Protactinium 91 231.03588 Solid 5.89 1572 4000
Uranium 92 238.02891 Solid 6.1941 1135 3927
Neptunium 93 237 Synthetic 6.2657 644 4000
Plutonium 94 244 Synthetic 6.026 640 3230
Americium 95 243 Synthetic 5.9738 1176 2011
Curium 96 247 Synthetic 5.9914 1345 3110

The interesting thing to note about this too is that this page is pretty heavy. It has many tables with the Periodic elements. However, by using client side code, we download all of the elements only once when we get our JavaScript file. The client side functionality does the page building, helping the page load quicker.

For those of you who have been web coding for a while, these few number of lines to have all of this client side functionality is magic. Seriously, magic.

You can either visit http://angularperiodic.azurewebsites.net/ to see the code in action and as always find the code out on GitHub