如何从span标签angular js 1获取数据

时间:2018-02-20 03:10:08

标签: angularjs angular1.6

我有桌子

<table class="table">
    <thead>
        <tr>
            <th>N0</th>
            <th>Produrce</th>
            <th>Price</th>
            <th>Unit</th>
        </tr>
    </thead>
    <tbody>
        <tr ng-repeat="paym in prices">
            <td>{{paym.num}}</td>
            <td>{{paym.name}}</td>
            <td>{{paym.payment}}</td>
            <td>{{paym.unit}}</td>
        </tr>
    </tbody>
    <tfoot>
        <tr>
            <td colspan="2"><span class="sp-total-lbl"> Total Amount</span></td>
            <td align="right"><span id="span-amount">{{getTotal())}}</span></td>
        </tr>
        <tr>
            <td colspan="4">
                <button ng-click="check_verify()" class="btn-primary">
                    <i class="material-icons">add</i>Check
                </button>
            </td>
        </tr>
    </tfoot>
</table>

此处getTotal()功能

$scope.getTotal =function(){
 var total = 0;
 for(var i = 0; i < $scope.prices.length; i++){
    var p = $scope.prices[i];
    total += parseInt(p.payment);
 }
 return total;
}

我的问题是什么?当我点击按钮Check来电check_verify()时,我想问一下,我想要提醒总价。

$scope.check_verify =function(){
    alert($scope.getTotal);
}

我尝试这样但是没有获得结果数据,它返回功能代码,任何一个人如何从总价中获得价值数据?

1 个答案:

答案 0 :(得分:1)

您忘记了cc_library( name = "impl", srcs = ["Implementation.cpp"] + select({ "@bazel_tools//src/conditions:windows": ["ImplementationWin.cpp"], "@bazel_tools//src/conditions:darwin": ["ImplementationMacOS.cpp"], "//conditions:default": ["ImplementationLinux.cpp"], }), # .. same for hdrs and data ) cc_binary( name = "demo", deps = [":impl"], ) 进行函数调用。

()