gpt4 book ai didi

javascript - 过滤产生错误结果 Angularjs

转载 作者:行者123 更新时间:2023-11-30 15:47:24 24 4
gpt4 key购买 nike

我有一个像这样的过滤器:

$scope.Approved = $filter('filter')($scope.Summary.CorpEmployees, { locationId: item.Label, evaluationStatusId: '3' });

由于某种原因,过滤器正在提取 evaluationStatusId = 13 的记录。有人可以解释为什么会这样吗?我如何才能确保我的过滤器只提取那些 evaluationStatusId = 3

的记录

最佳答案

根据我的评论:

You have to use the strict equality parameter called "comparator" in the angularjs docs, otherwise it does a "contains" rather than an "equals" for the filter.

See angular docs for filter here

它看起来像这样:

$scope.Approved = $filter('filter')(
$scope.Summary.CorpEmployees,
{ locationId: item.Label, evaluationStatusId: '3' },
true // <--- This is the parameter that forces strict equality
);

关于javascript - 过滤产生错误结果 Angularjs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39862936/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com