【问题标题】:How to set the outer div values in html page如何在html页面中设置外部div值
【发布时间】:2015-07-16 16:09:29
【问题描述】:

我在 Angularjs 中有一个 html 页面。在页面中有两个 div,一个包含有关用户总数的数据,另一个 div 包含从服务中填充数据的表,即用户列表。

代码是。

app_user.html

// IN this div i am getting the total no of users by users.length
<div id ="total_user"> no of users {{users.length}} </div>

<div id ="user_table">
// In this the no of users keeps changing as soon filter is applied
<tr ng-repeat="row in users | filter : {status: search['_status']} | filter : {payment_type:search['pay_type']}| orderBy : orderBy:reverse ">
                        <td >
                            <div ng-if="row.status !== 'Failure'"><!--{{$index}} -->

                                <input type="checkbox" checklist-model="user.roles" checklist-value="row.id">
                            </div>
                        </td>
                        <td>
                            <a ng-href="https://userapp.com/{{row.id}}" target="_blank">{{row.username}}</a>
                        </td>
                        <td>
                            <div>
                                <div>{{row.location}}</div>
                            </div>
                        </td>
</div>

在第一个 div 中,我找到了用户总数,在第二个 div 中,我显示了包含详细信息的用户列表。 我已经应用了运行良好的过滤器。现在我想要的是当我应用过滤器时,用户的数量也应该针对应用的特定过滤器进行更改。我不知道如何将row.length 传递给外部 div。

例如:在应用过滤器之前,我的用户总数为 100,当我应用过滤器时,用户总数现在为 40。现在在第一个 div 中,我想将用户总数显示为 40 而不是100.

【问题讨论】:

  • 问题不清楚..请详细说明
  • @PankajParkar ..我已经对我的问题进行了编辑..我希望它会有所帮助
  • @Mahesh Sapkal 添加的答案是您想要的准确答案

标签: html angularjs


【解决方案1】:

请使用以下方式获取计数。

ng-repeat="row in filteredusers = (users | filter:{status: search['_status']} | filter : {payment_type:search['pay_type']} | orderBy:reverse)"

将动态创建过滤列表,您可以在当前范围内的任何其他位置使用filteredusers.length 来显示计数。

过滤计数

{{filteredusers.length}}

【讨论】:

    猜你喜欢
    • 2018-03-21
    • 2021-01-08
    • 2013-08-11
    • 2015-08-23
    • 2014-10-07
    • 2016-11-03
    • 2019-11-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多