javascript - 如何使用角度创建搜索栏
问题描述
搜索 : ____________
我想创建一个搜索栏,当用户尝试输入等于或大于 8 个字的输入文本时,它应该触发并存储变量并重置搜索栏并检查后端 API 并且在后端找到一个,然后它应该显示如果未找到计数增量或 ELSE,则应显示在表中。
注意:我想在没有搜索按钮的情况下触发它,并且不应该计算空格。
例如:
搜索:qwerr121
找到:计数:1
未找到表:qwerr121
if text == 16:检查后端找到 = found + 1 else:array = [qwerr121]
谢谢
这是我的 js 代码,但我该如何处理 Angular
JS code:
const input = document.getElementById('input');
let data;
input.addEventListener('input', (e) => {
const inputValue = e.target.value;
if (inputValue.length === 11) {
data = inputValue;
e.target.value = '';
}
});
Html:
<input type="text" id="input">
解决方案
推荐阅读
- postgresql - 如何在 Debian docker 映像上安装 postgresql-client
- r - 如何用 R 中的时间列表填充 NA?
- javascript - 如何在进度条完成之前禁用 onlick 事件?
- angular - 空返回的 switchMap 不起作用 - 错误“无法读取 null 的属性 'uid'”
- tsql - 按日期分组行
- javascript - 钩子状态需要一段时间才能更新
- javascript - 带有 svg(图像)而不是点的斐波那契球体
- javascript - 如何阅读打字稿中的实例装饰器?
- python - 如何使 Treeview 中的“加号”跟随缩进?
- c - 正则表达式在 C 中获取完整名称