douge3830 2016-09-12 06:46
浏览 37
已采纳

如何使用angularjs在mysql中存储数学函数值?

I am creating invoice generator. In that I want to store the total,discount and all things in my database. Total and discount are calculated as follow...

<tr ng-repeat="list in data">
  <td> 
    <label class="clabel">Subtotal</label>
  </td>
  <td ng-model="subtotal">{{list.sale_price*list.quantity}}</td>
</tr>
<tr ng-repeat="list in data">
  <td> 
    <label class="clabel">Tax(2%)</label>
  </td>
  <td ng-model="tax">{{((list.sale_price*list.quantity)*2)/100}}</td>
</tr>
<tr ng-repeat="list in data">
  <td> 
    <label class="clabel">Discount(%)</label>
  </td>
  <td ng-model="discount">{{((list.sale_price*list.quantity)*list.discount)/100}}</td>
</tr>
<tr ng-repeat="list in data">
  <td> 
    <label class="clabel">Total</label>
  </td>
  <td ng-model="total">{{((list.sale_price*list.quantity)+(((list.sale_price*list.quantity)*2)/100))-(((list.sale_price*list.quantity)*list.discount)/100)}}</td>
</tr>
<tr>
    <td colspan="2">
    <button class="btn btn-success" style="margin-left:400px;" ng-click="GenerateBill();updateAll()">Generate Invoice</button>
    </td>
</tr>

Now I want to save the calculated values in my database.which means I want to store list.sale_price*list.quantity 's value.

js part is here..

$scope.updateAll = function(){

    data={
        qnt:$scope.qnt,
        subt:$scope.subtotal,
        tax:$scope.tax,
        dis:$scope.discount,
        total:$scope.total
    }
    $http.post("../POS_System/widget/updateAll.php?barcode="+$scope.barcode,data).success(function(data){

    });

please help me out...

  • 写回答

1条回答 默认 最新

  • dphdh395195 2016-09-14 04:50
    关注

    you can try this....

    $scope.updateAll=function()
    { 
         data={
                    subtotal:$scope.product.sale_prize*$scope.product.quantity,
                    tax:$scope.product.sale_prize * $scope.product.quantity*2/100,
                    discount:$scope.product.sale_prize * $scope.product.quantity*$scope.product.discount/100,
                    total:$scope.product.sale_prize * $scope.product.quantity+$scope.product.sale_prize * $scope.product.quantity*2/100-$scope.product.sale_prize *$scope.product.quantity* $scope.product.discount/100
    
             }
    
            $http.post("../pos_system/Widgets/updatedata.php?barc="+$scope.barc,data).success(function(data)
           { 
               //do your stuff here;
            });
     }
    

    Make this change in your HTML part

    <tr >
      <td> 
        <label class="clabel">Subtotal</label>
      </td>
      <td><input type="text" class="cinput" placeholder="sale price"  ng-value="list.sale_price*list.quantity" readonly="" />
      </td>
    </tr>
    <tr >
      <td> 
        <label class="clabel">Tax(2%)</label>
      </td>
      <td><input type="text" class="cinput" placeholder="sale price"  ng-value="((list.sale_price*list.quantity)*2)/100" readonly="" />
      </td>
    </tr>
    <tr>
      <td> 
        <label class="clabel">Discount(%)</label>
      </td>
      <td>
      <input type="text" class="cinput" placeholder="sale price"  ng-value="((list.sale_price*list.quantity)*list.discount)/100" readonly="" />
      </td>
    </tr>
    <tr >
      <td> 
        <label class="clabel">Total</label>
      </td>
      <td >
      <input type="text" class="cinput" placeholder="sale price"  ng-value="((list.sale_price*list.quantity)+(((list.sale_price*list.quantity)*2)/100))-(((list.sale_price*list.quantity)*list.discount)/100)" readonly="" />
      </td>
    </tr>
    <tr>
        <td colspan="2">
        <button class="btn btn-success" style="margin-left:400px;" ng-click="GenerateBill();updateAll()">Generate Invoice</button>
        </td>
    </tr>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大