Hey Guys, 

I'm working on a demo app that let's a user add their budget to a list, I 
got everything working fine. The problem that I'm having is, let's say I 
have a budget of $10,000 and every time a new object is added the Actual 
Expenses is subtracted from the $10,000 budget.

angular.module('LumpSumApp', [])
  .controller('LumpSumController', function() {
    var lumpSumList = this;

    lumpSumList.lumpsums = [];

    lumpSumList.addLumpSum = function() {

      var lumpsum = {
        lumpSumType: lumpSumList.lumpSumType,
        lumpSumCategory: lumpSumList.lumpSumCategory,
        lumpSumEstimate: lumpSumList.lumpSumEstimate,
        lumpSumExpenses: lumpSumList.lumpSumExpenses
      };

      lumpSumList.lumpsums.push(lumpsum);

      lumpSumList.lumpSumType = '';
      lumpSumList.lumpSumCategory = '';
      lumpSumList.lumpSumEstimate = '';
      lumpSumList.lumpSumExpenses = '';
    };

  });


<body ng-controller="LumpSumController as lumpSumList">
  <form class="form-inline" ng-submit="lumpSumList.addLumpSum()">
    <div class="form-group">
      <select class="form-control" ng-model="lumpSumList.lumpSumType">
        <option value=''>Select a Type</option>
        <option>2</option>
        <option>3</option>
        <option>4</option>
        <option>5</option>
      </select>
    </div>
    <div class="form-group">
      <select class="form-control" ng-model="lumpSumList.lumpSumCategory">
        <option value=''>Select a Category</option>
        <option>2</option>
        <option>3</option>
        <option>4</option>
        <option>5</option>
      </select>
    </div>
    <div class="form-group">
      <input class="form-control" type="text" 
ng-model="lumpSumList.lumpSumEstimate" size="40" placeholder="Estimated 
Expenses">
    </div>
    <div class="form-group">
      <input class="form-control" type="text" 
ng-model="lumpSumList.lumpSumExpenses" size="40" placeholder="Actual Expenses">
    </div>
    <div class="form-group">
      <label class="btn btn-primary">
        <i class="fa fa-file-text-o" aria-hidden="true"></i>
        <input type="file" ng-model="lumpSumList.lumpSumQuote" style="display: 
none;">
      </label>
    </div>
    <div class="form-group">
      <label class="btn btn-primary">
        <i class="fa fa-file-text-o" aria-hidden="true"></i>
        <input type="file" ng-model="lumpSumList.lumpSumReceipt" 
style="display: none;">
      </label>
    </div>
    <input class="btn btn-primary" type="submit" value="add">
  </form>


  <div class="table-responsive">
    <table class="table">
      <thead>
        <tr>
          <th>Expense Type</th>
          <th>Expense Category</th>
          <th>Estimated Expenses</th>
          <th>Actual Expenses</th>
          <th>Upload Quote(s)</th>
          <th>Upload Receipt(s)</th>
        </tr>
      </thead>
      <tbody>
        <tr ng-repeat="lumpsum in lumpSumList.lumpsums">
          <td>{{lumpsum.lumpSumType}}</td>
          <td>{{lumpsum.lumpSumCategory}}</td>
          <td>{{lumpsum.lumpSumEstimate}}</td>
          <td>{{lumpsum.lumpSumExpenses}}</td>
          <td>{{lumpsum.lumpSumQuote}}</td>
          <td>{{lumpsum.lumpSumReceipt}}</td>
        </tr>
      </tbody>
    </table>
  </div>

</body>

</html>


-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to