css - Angular:将固定搜索栏添加到垫选择下拉列表中
问题描述
我在我的应用程序中使用mat-select小部件(Angular-Material)
我在选择下拉列表的顶部实现了一个搜索栏来过滤选项:
<mat-select placeholder="Selectionner la boutique"
id="libelleShop">
<div id="custom-search-input" class="m-1 navbar-fixed-top">
<input #shopKeyword matInput placeholder="Search" class="search-input" (keyup)="filterShopsByLibelle(shopKeyword.value)">
<span class="input-group-btn">
<button class="btn btn-danger" type="button">
<span class="glyphicon glyphicon-search"></span>
</button>
</span>
</div>
<mat-option *ngFor="let shop of bad3ShopsListSortedByName"
[value]="shop.edoId">
{{shop.storeName}}
</mat-option>
</mat-select>
我的目的是如何将搜索 Bard div (#custom-search-input) 固定在顶部。
我试过position: fixed
了,但似乎不起作用
建议??
解决方案
解决方案 1
<mat-select-search [formControl]="formControlName"></mat-select-search>
在 mat-select 中添加这个标签,并按照 StackBlitz 的app.component.ts中的步骤进行操作
解决方案 2
您可以使用Angular 材料的自动完成功能
https://material.angular.io/components/autocomplete/overview
推荐阅读
- java - Do-While 循环错误 - 不再重复玩游戏
- python - 第二个窗口中的 PyQt5 按钮不起作用
- php - 在apache服务器的子目录中部署laravel时base_path错误
- linux - kernel_init 标记为 __ref
- javascript - Async Javascript:试图间隔多次进行 AJAX API 调用?
- maya - Unreal Viewer 中骨骼中的红色骨骼是什么?
- ruby-on-rails - 如何编写一个简单的 if 语句来检查当前用户是否已经查看过某些内容?
- google-api - 如何使用 Nodejs 获取视频观看次数 youtube api
- javascript - 跨域跟踪 Iframe 跟踪错误 id
- reactjs - 在 Mac 上的终端中运行 create-react-app 时出现异常错误