angular - 如何为 ngSelect 选项添加工具提示?在将选项悬停在下拉列表中时,我需要显示工具提示
问题描述
<ng-select [items]="cities"
bindLabel="name"
placeholder="Select city"
[(ngModel)]="selectedCity">
</ng-select>
如何为 ngSelect 选项添加工具提示?在将选项悬停在下拉列表中时,我需要显示工具提示。
解决方案
使用选项模板,您可以在这些模板中添加工具提示。
在下面的示例中,我使用 HTML 属性title
来显示工具提示,如果您使用像 ng-bootstrap 这样的库,那么您可以使用该库中的工具提示功能。
<ng-select [items]="cities" [(ngModel)]="selectedCity" bindLabel="name" bindValue="name">
<ng-template ng-option-tmp let-item="item" let-index="index" let-search="searchTerm">
<span title="A sample info in tooltip">{{item.name}}</span>
</ng-template>
</ng-select>
推荐阅读
- php - 如何使用php从csv文件中动态获取列值
- javascript - 使用 forEach 循环在一个数字范围内循环,并将任何包含整数 1 的数字替换为“Beep”
- vb.net - VB.NET 数据库事务不去数据库
- sql - 旧作业和新作业列 SQL
- reactjs - react-hook-form 版本 7 验证错误不起作用
- python - 有没有办法使用 Python 在 docx 文件上将图像换行设置为“通过”?
- excel - 基于动态范围创建数据透视表
- node.js - Google Cloud Storage NodeJS 多个读取请求加载太慢
- string - 硬编码字符串变为粗体
- powershell - 点源文件低于一级?