我想在触发提交按钮时显示成功消息,但仅在10次某种时间之后,为此我写了以下几行。
let timeoutId = setTimeout(() => {
this.success = true;;
},500);
Simmilarly,我想在一段时间后关闭消息,让我们5秒。任何人都可以建议我怎么做。谢谢。
答案 0 :(得分:1)
/*
string = {"Canna Terra PLUS 50 Litres", "Canna Vega Tent", "Canna Bio Vega", "Super Canna 50 max" }
search = "Canna Vega" this can be dynamic ranging up to 4 words search term
The expected return array would be
{"Canna Vega Tent", "Canna Bio Vega" }
*/
function loadSuggest(string,search){
if( search.length < 3 ){
return; // suggest is loaded only if the search term is more than 3 letter
}
var terms = search.split(' '); // split the search term with spaces
var i;
for(i = 0; i < string.length; i++){
/*
how to dynamically check and return
the results containing more than one term match ?
I have tried indexOf() but that fails with dynamic number of words matching
*/
}
return resultArray;
}
答案 1 :(得分:1)
Observable.timer(500).subscribe(() => {
this.success = true;
Observable.timer(5000).subscribe(() => this.success = false);
});