【发布时间】:2019-07-23 09:37:16
【问题描述】:
我有一个下拉框,我想使用来自查询的响应进行过滤。
$scope.retrieveUsers = function () {
SpringDataRestService.query(
{
"collection": "users"
},
function (response) { // Success Function
$scope.users = response.users;
}
);
};
此方法当前重试所有用户,以下 JSON 是这样的:
[ {
"status" : "Dead",
"name" : "Holy Moly"
}, {...
由于网络服务的性质,我不能使用标记为 userInternal 的服务,因为它包含用户所拥有的不存在的信息。
$scope.userList = [];
SpringDataRestService.get(
{"collection": "userInternal"},
function (response) { // Success Function
var users = response._embedded.userInternal;
for (var i = 0, len = users.length; i < len; i++) {
if (retrieveUsers === "PENDING_DEACTIVATION") {
var newUser= {id: users[i].id, name: users[i].name};
$scope.userList.push(newUser);
}
}
},
function (response) { // Failure Function
console.log(JSON.stringify(response));
}
);
所以我认为 if 语句会起作用,但我真的不知道我会用什么来使该函数正常工作?任何人都可以帮忙吗?我认为其余的代码都在工作,如果我不知道该怎么做,那只是实际的。
【问题讨论】: