https://github.com/syncfusionexamples/ej2-ng-dropdownlist-tooltip
Showing tooltip for Angular Dropdownlist items in popup
https://github.com/syncfusionexamples/ej2-ng-dropdownlist-tooltip
angular angular-dropdownlist dropdownlist
Last synced: 21 days ago
JSON representation
Showing tooltip for Angular Dropdownlist items in popup
- Host: GitHub
- URL: https://github.com/syncfusionexamples/ej2-ng-dropdownlist-tooltip
- Owner: SyncfusionExamples
- License: mit
- Created: 2017-11-20T13:56:52.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-10-17T04:02:38.000Z (9 months ago)
- Last Synced: 2025-04-03T11:02:56.044Z (3 months ago)
- Topics: angular, angular-dropdownlist, dropdownlist
- Language: JavaScript
- Homepage:
- Size: 26.4 KB
- Stars: 0
- Watchers: 16
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# DropDownList items with Tooltip for Angular
## Tooltip is displayed for the selected item in DropDown element
By using title attribute with change event handler, you can enable the tooltip support to selected item which is shown in input element. Whenever selection changed, need to update the title attribute value from selected item’s text content. Please refer the below code snippet,
```
public onChange: any = (args: SelectEventArgs) => {
let dropDownObj: HTMLElement = document.getElementById('ddlelement');
dropDownObj.setAttribute('title', args.item.textContent);
}
```## Tooptip for all the list items in dropdown popup
We can enable the tooltip option to all the list items by using title attribute with open event.Please refer the below code snippet for enable the tooltip for all the list items in open event handler.
```
public onOpen: any = (args:PopupEventArgs) => {
// get all the list items
let listItems: any = args.popup.element.querySelectorAll('li');
let length: number = listItems.length;
for (let i: number = 0; i < length; i++) {
// set title attribute to all the list items.
listItems[i].setAttribute('title', listItems[i].textContent);
}
}```
## Installing and Running Application
### Installing
To install all dependent packages, use the below command
```
npm install
```### Run the application
To compile and run the source files, use the below command
```
npm start
```