小编Jay*_*rex的帖子

如何获取angularjs列中的总值?

我是 angularjs 的新手。如何获取表格总金额列中的总金额并显示在输入文本框中?我认为这个 plunker 可以解决我的问题,但我现在无法访问它。http://plnkr.co/edit/CHBm8RCqW5RNZWrzAe5r?p=preview

这是我的表样本

在此处输入图片说明

<table>
                <thead>
                    <tr>

                        <th>Product</th>
                        <th>Quantity</th>
                        <th>Total Amount</th>


                    </tr>
                </thead>
                <tbody>
                    <tr ng-repeat="payment_queue in data | filter:searchFilter">

                        <td>{{payment_queue.product_name}}</td>
                        <td>{{payment_queue.sold_quantity}}</td>
                        <td>{{payment_queue.amount}}</td>

                    </tr>
                </tbody>
            </table>

Total Amount: <input type="text value=""> <--- the total amount value goes here...
Run Code Online (Sandbox Code Playgroud)

js

var myApp = angular.module('myApp', ['ngRoute']); 
    myApp.controller('productsalesController', ['$scope', '$http', function ($scope, $http) {



                    $scope.data=[];

                    $http.get("../php/paymentQueuedata.php")
                        .success(function(data){
                            $scope.data = data;
                        })
                        .error(function() {
                            $scope.data = "error in fetching data";
                        });

         }]);
Run Code Online (Sandbox Code Playgroud)

php json

    <?php
    //database settings
    $connect = mysqli_connect("localhost", "root", …
Run Code Online (Sandbox Code Playgroud)

angularjs

3
推荐指数
1
解决办法
2万
查看次数

如果x <= y,那么x = 600 y = 1000?

什么是正确或正确的方式?我对此感到困惑.有人能说得对吗?

3digit <= 4digitfalse
4digit <= 3digittrue

你可以在这里测试一下:JSFiddle

<h2></h2>
<form id="send" action="#" method="POST">
    <input type="text" id="x"><br/>
    <input type="text" id="y">
    <input type="submit">
</form>
Run Code Online (Sandbox Code Playgroud)
$(document).ready(function() {
    $('#send').submit(function(){
        var x = $('#x').val();
        var y = $("#y").val();
        if (x <= y) {
            $('h2').html("Done.");
        } else {
            $('h2').html("Sorry,not enough cash.");
        }
        event.preventDefault();
    });
});
Run Code Online (Sandbox Code Playgroud)

jquery

2
推荐指数
2
解决办法
132
查看次数

标签 统计

angularjs ×1

jquery ×1