Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/385.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 构建我自己的自动完成angularjs_Javascript_Angularjs_Autocomplete - Fatal编程技术网

Javascript 构建我自己的自动完成angularjs

Javascript 构建我自己的自动完成angularjs,javascript,angularjs,autocomplete,Javascript,Angularjs,Autocomplete,我试图建立我自己的搜索功能与自动完成 Search MAC:<br/> <input type="text" ng-model="boxtext"> <tr ng-repeat="box in boxes | filter:boxtext"> <td>{{box.type}}</td> <td>{{box.mac}}</td> <td>{{box.serial}}</td>

我试图建立我自己的搜索功能与自动完成

Search MAC:<br/>
<input type="text" ng-model="boxtext">

<tr ng-repeat="box in boxes | filter:boxtext">
  <td>{{box.type}}</td>
  <td>{{box.mac}}</td>
  <td>{{box.serial}}</td>
 </tr>
</table>
搜索MAC:
{{box.type} {{box.mac}} {{box.serial}}
我现在遇到的问题是,框中的所有行都被打印出来,当我开始在文本字段中键入时,这些行被过滤掉

当我开始在文本字段中输入时,我真的不知道如何打印“框”中的行?有什么建议吗?

您只需在预览表中添加:

<input type="text" ng-model="boxtext">

<table ng-if="boxtetxt.length > 0">
 <tr ng-repeat="box in boxes | filter:boxtext">
  <td>{{box.type}}</td>
  <td>{{box.mac}}</td>
  <td>{{box.serial}}</td>
 </tr>
</table>

{{box.type}
{{box.mac}}
{{box.serial}}

这样,只要
boxtext.length>0
为false,表就会被删除。请注意,
boxtext
必须初始化为空字符串,否则它将是
null
未定义的
,并且不会有
长度

OFC!我这样做了,但是在我的tr标签上,它不起作用。。谢谢:)@Bryan很高兴它起了作用。如果这回答了您的问题,请接受答案,这样问题就会显示为已回答,您为什么不看看这个: