title: (AngularJS) Calculate dynamically subtotals for each different Percentage
body: <p>I am new to AngularJS and would be very grateful for a tip. I have a table with a column amount, and two columns of percentages. In these two columns, the user can enter different percentages. </p>
  
  <p>Now I want to sum ​​up the amounts with the same percentages first and then multiplied by the percentage. A Subtotal row should then be created dynamically for each percentage.</p>
  
  <p>Can you give me a hint? Here is a fiddle, to demonstrate it: <a href="http://jsfiddle.net/marmuel/3H63C/2/" rel="nofollow">fiddle</a></p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;table ng:controller="SubTotalCtrl"&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th ng:repeat="(i,th) in head" ng:class="selectedCls(i)" ng:click="changeSorting(i)"&gt;{{th}}&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr ng:repeat="row in body.$orderBy(sort.column, sort.descending)"&gt;
              &lt;td&gt;&lt;input value = {{row.a}}&gt;&lt;/input&gt;&lt;/td&gt;
              &lt;td&gt;&lt;input value = {{row.b}}&gt;&lt;/input&gt;&lt;/td&gt;
              &lt;td&gt;&lt;input value = {{row.c}}&gt;&lt;/input&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
      &lt;tfoot&gt;
          &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;textarea&gt;Label Subtotal Percent 5&lt;/textarea&gt;&lt;/td&gt;      
          &lt;td&gt;= (Sum of all Amounts with 5% *  5 %)&lt;/td&gt;
           &lt;/tr&gt;&lt;tr&gt; 
           &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;textarea&gt;Label Subtotal Percent 10&lt;/textarea&gt;&lt;/td&gt;      
          &lt;td&gt;= (Sum of all Amounts with 10% *  10 %)&lt;/td&gt;
          &lt;/tr&gt;&lt;tr&gt; 
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;textarea&gt;Label Subtotal Percent 20&lt;/textarea&gt;&lt;/td&gt;      
          &lt;td&gt;= (Sum of all Amounts with 20% * 20%)&lt;/td&gt;
           &lt;/tr&gt;        
  &lt;/table&gt;
  </code></pre>
  
  <p><strong>SCRIPT</strong></p>
  
  <pre><code>function SubTotalCtrl() {
      var scope = this;
  
      // data
      scope.head = {
          a: "Amount",
          b: "Percent",
          c: "Percent"
      };
      scope.body = [{
          a: "1000",
          b: "5",
          c: "10"
      }, {
          a: "2000",
          b: "0",
          c: "5"
      }, {
          a: "3000",
          b: "10",
          c: "20"
      }];
  }
  </code></pre>