I have a data array which contains many objects (JSON format).
(我有一个包含许多对象(JSON格式)的数据数组。)
The following can be assumed as the contents of this array:(以下可以假设为此数组的内容:)
var data = [
{
"name": "Jim",
"age" : 25
},
{
"name": "Jerry",
"age": 27
}
];
Now, I display these details as:
(现在,我将这些细节显示为:)
<div ng-repeat="person in data | filter: query">
</div
Here, query is modeled to an input field in which the user can restrict the data displayed.
(这里,查询被建模为输入字段,其中用户可以限制所显示的数据。)
Now, I have another location in which I display the current count of people / person being display, ie Showing {{data.length}} Persons
(现在,我有另一个位置,我在其中显示当前显示的人/ Showing {{data.length}} Persons
,即Showing {{data.length}} Persons
)
What I want to do is that when the user searches for a person and the data displayed is filtered based on the query, the Showing...persons
also change the value of people being shown currently.
(我想要做的是,当用户搜索一个人并且根据查询过滤显示的数据时, Showing...persons
也会更改当前Showing...persons
的值。)
But it is not happening.(但它没有发生。)
It always displays the total persons in data rather than the filtered one - how do I get the count of filtered data?(它始终显示数据中的总人数而不是过滤数据 - 如何获取过滤数据的计数?)
ask by user109187 translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…