gpt4 book ai didi

javascript - Angular js 自动完成搜索和链接

转载 作者:行者123 更新时间:2023-12-03 09:22:29 25 4
gpt4 key购买 nike

我正在尝试使用链接实现自动完成搜索(选择后应该跳转到特定页面)。只需我需要隐藏搜索框下方显示的数据,它应该仅在用户开始输入(如搜索功能)时显示。

下面有两个屏幕截图,第一个是我所做的,其中数据默认填充,所以我希望将其隐藏,当我输入它时,它应该像 screen2 一样显示 enter image description here

data is getting populated from database using json but i need to hide the content apearing after input box, it shoul only come when i type the relevant text

<!DOCTYPE html>
<html>
<head>
<title>Angular JS</title>

<style>
ul,li{margin:0; padding:0;}
</style>
</head>
<body>
<div ng-app="myApp" ng-controller="movieCtrl">
<input type="text" ng-model="film">
<ul>
<li ng-repeat="x in movies | filter:film | orderBy:'film'" style="list-style-type:none;"><a href="{{ x.param }}">{{ x.film | uppercase }}</a></li>
</ul>

</div>

<script src="Scripts/angular.min.js"></script>
<script>
var app = angular.module('myApp', []);
app.controller('movieCtrl', function($scope, $http) {
$http.get("tmp.php")
.success(function(response) {$scope.movies = response.movie;});
});
</script>
</body>
</html>

最佳答案

向列表中添加一个条件,使其仅在过滤器不为空时可见:

<ul ng-show="film">
<li ng-repeat="x in movies | filter:film | orderBy:'film'" style="list-style-type:none;"><a href="{{ x.param }}">{{ x.film | uppercase }}</a></li>
</ul>

关于javascript - Angular js 自动完成搜索和链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31803599/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com