title: how to calculate total based on check box checked.?
body: <p>I'm trying to calculate checked total amount based on checkbox select, if checkbox select then total value should add. i have added screenshot below also in that i had explained clearly please go through that. in my main project what happen is 'checked total' showing in every child table if i click in other table, all table's checked total will change, but u want to show individual table check total.</p>
  
  <p>how can do this, i have uploaded code below</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var app = angular.module('MyApp', [])
  app.controller('MyController', function($scope) {
    $scope.Customers = [{
        CustomerId: 1,
        Name: "Prashant Olekar",
        Country: "United States",
        Orders: [{
            OrderId: 10248,
            Freight: 32.38,
            amount: 10000,
            ShipCountry: 'France'
          },
          {
            OrderId: 10249,
            Freight: 12.43,
            amount: 10000,
            ShipCountry: 'Japan'
          },
          {
            OrderId: 10250,
            Freight: 66.35,
            amount: 10000,
            ShipCountry: 'Russia'
          }
        ]
      },
      {
        CustomerId: 2,
        Name: "Hemant K",
        Country: "India",
        Orders: [{
            OrderId: 10266,
            Freight: 77.0,
            amount: 10000,
            ShipCountry: 'Argentina'
          },
          {
            OrderId: 10267,
            Freight: 101.12,
            amount: 10000,
            ShipCountry: 'Australia'
          },
          {
            OrderId: 10268,
            Freight: 11.61,
            amount: 10000,
            ShipCountry: 'Germany'
          }
        ]
      },
      {
        CustomerId: 3,
        Name: "Richard",
        Country: "France",
        Orders: [{
          OrderId: 10250,
          Freight: 65.83,
          amount: 10000,
          ShipCountry: 'Brazil'
        }]
      },
      {
        CustomerId: 4,
        Name: "Robert Schidner",
        Country: "Russia",
        Orders: [{
            OrderId: 10233,
            Freight: 89.11,
            amount: 10000,
            ShipCountry: 'Belgium',
          },
          {
            OrderId: 10234,
            Freight: 51.30,
            amount: 10000,
            ShipCountry: 'Canada'
          },
          {
            OrderId: 10235,
            Freight: 46.11,
            amount: 10000,
            ShipCountry: 'Austria'
          }
        ]
      }
    ];
  
     $scope.innertotalvalue = function (itemOrder) {
          if (itemOrder != undefined) {
              var innertotalvalue = 0;
              for (j = 0; j &lt; itemOrder.Orders.length; j++) {
                  if (itemOrder.Orders[j].amount != 0) {
                      innertotalvalue = innertotalvalue + itemOrder.Orders[j].amount;
                  }
              }
          }
          return innertotalvalue;
      }
  
  
    $scope.chkselect_onchange = function(c, item) {
      var totalvalue = 0;
      var ordercount = 0;
      var customercount = 0;
  
      angular.forEach(c, function(cust) {
        angular.forEach(cust.Orders, function(order) {
          if (cust.select == true) {
            if (order.amount != 0) {
              order.select = true;
            } else {
              order.select = false;
            }
          } else {
            order.select = false;
          }
        })
      })
    }
  
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!-- Latest compiled and minified CSS --&gt;
  &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"&gt;
  &lt;!-- Latest compiled and minified JavaScript --&gt;
  &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.9/angular.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"&gt;&lt;/script&gt;
  
  
  &lt;div ng-app="MyApp" ng-controller="MyController"&gt;
    &lt;div class="container" style="margin-top:40px;"&gt;
      &lt;div class="row"&gt;
        &lt;div class="col-md-12"&gt;
          &lt;table class="table table-condensed table-bordered table-hover"&gt;
            &lt;thead&gt;
              &lt;tr&gt;
                &lt;td&gt;&lt;/td&gt;
                &lt;th&gt;Customer Id&lt;/th&gt;
                &lt;th&gt;Name&lt;/th&gt;
                &lt;th&gt;Country&lt;/th&gt;
                &lt;th&gt;Orders&lt;/th&gt;
              &lt;/tr&gt;
            &lt;/thead&gt;
            &lt;tbody ng-repeat="c in Customers"&gt;
              &lt;tr&gt;
                &lt;td&gt;
                  &lt;input id="mainCheck" type="checkbox" ng-change="chkselect_onchange(Customers,c)" ng-model="c.select" /&gt;&lt;/td&gt;
                &lt;td&gt;{{c.CustomerId}}&lt;/td&gt;
                &lt;td&gt;{{c.Name}}&lt;/td&gt;
                &lt;td&gt;{{c.Country}}&lt;/td&gt;
                &lt;td&gt;
                  &lt;table class="table table-condensed table-bordered"&gt;
                    &lt;thead&gt;
                      &lt;tr&gt;
                        &lt;th&gt;&lt;/th&gt;
                        &lt;th&gt;Order Id&lt;/th&gt;
                        &lt;th&gt;Freight&lt;/th&gt;
                        &lt;th&gt;ShipCountry&lt;/th&gt;
                        &lt;th&gt;Amount&lt;/th&gt;
                      &lt;/tr&gt;
                    &lt;/thead&gt;
                    &lt;tbody ng-repeat="o in c.Orders"&gt;
                      &lt;tr&gt;
                        &lt;td&gt;
                          &lt;input id="subCheck" type="checkbox" ng-change="chklotselect_onchange(Customers)" ng-model="o.select" /&gt;&lt;/td&gt;
                        &lt;td&gt;{{o.OrderId}}&lt;/td&gt;
                        &lt;td&gt;{{o.Freight}}&lt;/td&gt;
                        &lt;td&gt;{{o.ShipCountry}}&lt;/td&gt;
                        &lt;td&gt;{{o.amount}}&lt;/td&gt;
                      &lt;/tr&gt;
                    &lt;/tbody&gt;
                    &lt;tfoot&gt;
                      &lt;tr&gt;
                        &lt;td colspan="2"&gt;Checked Total:______&lt;/td&gt;
                        &lt;td&gt;&lt;/td&gt;
                        &lt;td colspan="2"&gt;&lt;span class="pull-right"&gt;Total:{{innertotalvalue(c)}}&lt;/span&gt; &lt;/td&gt;
                      &lt;/tr&gt;
                    &lt;/tfoot&gt;
                  &lt;/table&gt;
                &lt;/td&gt;
              &lt;/tr&gt;
            &lt;/tbody&gt;
          &lt;/table&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>