Skip to content

Commit c758e68

Browse files
IvayloGLipata
authored andcommitted
feat(select): implement select-item text input #5989 (#6047)
1 parent 368e296 commit c758e68

File tree

3 files changed

+619
-461
lines changed

3 files changed

+619
-461
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
All notable changes for each version of this project will be documented in this file.
44

5+
56
## 9.0.0
67

78
### General
@@ -16,6 +17,14 @@ All notable changes for each version of this project will be documented in this
1617
- `IgxGrid`, `IgxTreeGrid`, `IgxHierarchicalGrid`
1718
- **Behavioral Change** - Pinning columns is no longer automatically prevented when the pinning area would exceed the size of the grid.
1819

20+
21+
## 8.2.6
22+
23+
### New Features
24+
- `IgxSelectItem`
25+
- `text` input is added. By default, the Select component will display the selected item's element inner text. In cases with a more complex item template, where more than just text interpolation is used, set the text property to specify what to display in the select field when the item is selected.
26+
27+
1928
## 8.2.4
2029
- `IgxGrid`, `IgxTreeGrid`, `IgxHierarchicalGrid`
2130
- The header text of the columns and the column groups now has the `title` attribute set to it in order to expose a native browser tooltip.

projects/igniteui-angular/src/lib/select/select-item.component.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,42 @@
11
import { IgxDropDownItemComponent } from './../drop-down/drop-down-item.component';
2-
import { Component, DoCheck } from '@angular/core';
2+
import { Component, DoCheck, Input } from '@angular/core';
33

44
@Component({
55
selector: 'igx-select-item',
66
template: '<ng-content></ng-content>'
77
})
88
export class IgxSelectItemComponent extends IgxDropDownItemComponent implements DoCheck {
99

10+
private _text: any;
11+
12+
/**
13+
* An @Input property that gets/sets the item's text to be displayed in the select component's input when the item is selected.
14+
*
15+
* ```typescript
16+
* //get
17+
* let mySelectedItem = this.dropDown.selectedItem;
18+
* let selectedItemText = mySelectedItem.text;
19+
* ```
20+
21+
* ```html
22+
* // set
23+
* <igx-select-item [text]="'London'"></igx-select-item>
24+
* ```
25+
*/
26+
@Input()
27+
public get text(): string {
28+
return this._text;
29+
}
30+
31+
public set text(text: string) {
32+
this._text = text;
33+
}
34+
1035
/** @hidden @internal */
1136
public get itemText() {
37+
if (this._text !== undefined) {
38+
return this._text;
39+
}
1240
return this.elementRef.nativeElement.innerText.trim();
1341
}
1442

0 commit comments

Comments
 (0)