【发布时间】:2019-05-10 05:55:42
【问题描述】:
问题陈述是我必须创建一个搜索功能,即使我输入小写或大写,我也可以搜索小写或大写元素
我尝试过大写搜索和小写搜索,但它根本不起作用,请尽快建议我
search(searchValue) {
if (searchValue != null && searchValue != "") {
var searchItem = searchValue;
var allOppData = this.stagesWiseOpportunitiesData;
var filtered = _.mapValues(allOppData, statuses =>
_.filter(statuses, statusT =>
_.some(statusT, T => _.includes(T, searchItem))
)
);
this.stagesWiseOpportunitiesData = filtered;
let stages = this.opportunitiesStateReason;
stages.forEach(element => {
let num = this.stagesWiseOpportunitiesData[element.orderData].reduce(
function(sum, value) {
return sum + value.expected_revenue;
},
0
);
element.totalExpectedRevenue = num.toFixed(2);
});
} else {
this.stagesWiseOpportunitiesData = this.stagesWiseOpportunitiesDataCopy;
let stages = this.opportunitiesStateReason;
stages.forEach(element => {
let num = this.stagesWiseOpportunitiesData[element.orderData].reduce(
function(sum, value) {
return sum + value.expected_revenue;
},
0
);
element.totalExpectedRevenue = num.toFixed(2);
});
}
}
}
【问题讨论】:
-
给我们一些例子和预期的输出
-
例如,如果有一个元素名称为 test 的表,那么如果我搜索 (Test,TEST,test) 它必须显示结果 test 完全相同的功能run.stackblitz.com/api/angular/…
-
您没有在搜索功能中返回任何内容。是这个错误吗?
-
返回总和 + value.expected_revenue;我已经退回了这个
-
好的,返回不正确。让我在答案中添加我的解决方案。我认为这可能是您的解决方案
标签: javascript angular typescript angular6