【发布时间】:2015-05-22 14:30:25
【问题描述】:
假设我在 HTML 中有这个
<div ng-repeat="tag in response.Tags | filter : searchKey">
</div>
我还有一个带有searchKey 模型的文本输入。
<input type="text" ng-model="searchKey">
response.Tags 是一个 JSON 数组。
现在的问题是,默认加载时,ng-repeat 填充的 UI 中缺少一些对象。当我使用文本输入并过滤列表时,我可以看到丢失的东西。
出了什么问题?
注意 - 数组没有变化。元素在那里。一旦加载它就不会改变。
编辑 这是我收到的原始数据。最多可包含 500 个元素,只有少数元素时不会遗漏任何内容。
{
"AlertCategoryID": 15,
"AlertName": "Disk Space Low",
"AlertType": "Warning",
"AlertMessage": "<data><summary>Available disk space (%) on drive _Total is less than 10%. Current value is 5%.</summary><detail></detail></data>",
"AlertTime": "2015-05-21T19:24:03"
}, {
"AlertCategoryID": 15,
"AlertName": "Disk Space Low",
"AlertType": "Warning",
"AlertMessage": "<data><summary>Available disk space (%) on drive _Total is less than 10%. Current value is 5%.</summary><detail></detail></data>",
"AlertTime": "2015-05-21T19:22:05"
}
我使用 XML 解析器来提取 <summary> 标记,我还截取并删除了日期和时间之间的 T;并将这些分配给我将用于 ng-repeat 的数组。
我在 UI 中显示 AlertName、Message 和它的时间。
我注意到倾向于丢失的元素在消息标记中有一个非常大的 XML。我不知道这是否与任何事情有关。
【问题讨论】:
-
你的
ng-model说searchQuery,而不是searchKey -
抱歉这里打错了。
-
不要在这里输入代码,总是复制/粘贴
-
您能否举一个
response.Tags的示例以及初始加载时最终丢失的内容?更好的是 Plunker 示例 -
感谢您的建议。不会再做了。
标签: javascript html angularjs angularjs-ng-repeat ng-repeat