angularjs - 在 Response Post 对象中传递从请求查询返回的数据
问题描述
我的 Angular 编码已经生锈了,因为我有一段时间没有这样做了,但是我想做的是获取从列表控制器返回的值列表,并将它们注入到我的响应帖子中到将使用此列表的搜索控制器搜索存储库。
这是我迄今为止尝试过的——
1 - 在 $scope.data{} 初始化程序中使用 Guid:[] 初始化列表数组
//Initailize
$scope.data = {
selection: null,
start: '',
end: '',
minDate: new Date(2017, 01, 01),
defaultStartDate: moment({ year: currentDate.getFullYear(), month: currentDate.getMonth(), day: currentDate.getDate() }),
defaultEndDate: moment({ year: currentDate.getFullYear(), month: currentDate.getMonth(), day: currentDate.getDate() + 1 }),
format: 'YYYY-MM-DD HH:mm:ss.SSS',
elasticUrl: '',
dnsHost: '',
messageTypes: [],
scrollId: '',
TID: '',
Guids: []
};
2 - 从搜索控制器返回我感兴趣的列表 $scope.Guids = data.Guids
var search = function () {
NProgress.start();
var ospLogsSearchParam = {
StartDate: $scope.data.start,
EndDate: $scope.data.end,
ElasticUrl: $scope.data.elasticUrl,
MessageTypes: $scope.data.messageTypes,
DnsHost: $scope.data.dnsHost,
TID: $scope.data.TID,
};
var queryString = $.param(ospLogsSearchParam);
$http.get("/api/search?" + queryString).success(function (data) {
$scope.isLoading = false;
$scope.total = data.Total;
$scope.took = "";
$scope.tookMins = "";
$scope.successCount = "";
$scope.errorCount = "";
$scope.tps = "";
$scope.Guids = data.Guids; (data list)
}).finally(function () {
NProgress.done();
});
}
3 - 将此值(Guids:$scope.data.Guids)注入 SearchParameter 对象的 Guids 字段,我将发送第二个搜索控制器。
function invokeParse() {
var ospLogsSearchParam = {
StartDate: $scope.data.start,
EndDate: $scope.data.end,
ElasticUrl: $scope.data.elasticUrl,
MessageTypes: $scope.data.messageTypes,
DnsHost: $scope.data.dnsHost,
TID: $scope.data.TID,
Guids: $scope.data.Guids (data trying to send to back end controller)
};
var parse = {
Logs: $scope.filteredItems,
DNSName: !$scope.data.dnsHost ? 'none' : $scope.data.dnsHost,
OspLogsSearchParams: ospLogsSearchParam
}
预期结果是后端搜索控制器将使用列表中的每个值作为 where 过滤器执行搜索。
实际结果是没有使用搜索请求中的值填充 guid 列表。
解决方案
推荐阅读
- fortran - 在fortran中使用dreal函数
- batch-file - 超过一定年龄的循环处理文件的批处理文件
- javascript - 如何制作像 Wikipedia 和 Facebook 这样的悬停效果
- c++ - 将原始内存数组 (char*) 的内容传递给 std::istream& 参数而不复制缓冲区内容?
- javascript - 如何使用 map 函数更改对象数组的值?
- php - 如何在 password_hash 第二个参数中使用变量?
- html - 带有 webp 后备和不同屏幕尺寸的 picutre srcset
- javascript - How to detect with jQuery or JavaScript when HTML5
- authentication - 有没有办法使用谷歌提供的客户端 ID 检查使用谷歌登录的用户数量
- swift - SwiftUI:寻找映射 API 响应的最佳方式