|
1 | | -import { Component } from '@angular/core'; |
2 | | -import { GlobalPositionStrategy, OverlaySettings } from 'igniteui-angular/core'; |
| 1 | +import { AfterViewInit, Component, ViewChild } from '@angular/core'; |
| 2 | +import { FormsModule } from '@angular/forms'; |
| 3 | +import { OverlaySettings } from 'igniteui-angular/core'; |
3 | 4 | import { IgxComboComponent } from 'igniteui-angular/combo'; |
4 | | -import { scaleInCenter, scaleOutCenter } from 'igniteui-angular/animations'; |
| 5 | +import { IgxLabelDirective } from 'igniteui-angular/input-group'; |
5 | 6 |
|
6 | 7 | @Component({ |
7 | 8 | selector: 'app-combo-overlay', |
8 | 9 | templateUrl: 'combo-overlay.component.html', |
9 | 10 | styleUrls: ['combo-overlay.component.scss'], |
10 | | - imports: [IgxComboComponent] |
| 11 | + imports: [IgxComboComponent, IgxLabelDirective, FormsModule] |
11 | 12 | }) |
12 | | -export class ComboOverlayComponent { |
13 | | - public items = [{ name: 'Option 1' }, { name: 'Option 2' }, { name: 'Option 3' }, |
14 | | - { name: 'Option 4' }, { name: 'Option 5' }, { name: 'Option 6' }, |
15 | | - { name: 'Option 7' }, { name: 'Option 8' }, { name: 'Option 9' }]; |
| 13 | +export class ComboOverlayComponent implements AfterViewInit { |
| 14 | + @ViewChild('combo', { static: true }) |
| 15 | + public combo: IgxComboComponent; |
16 | 16 |
|
| 17 | + public people = [ |
| 18 | + { name: 'Ana Petrova', department: 'Engineering' }, |
| 19 | + { name: 'Marc Lee', department: 'Engineering' }, |
| 20 | + { name: 'Priya Nair', department: 'Engineering' }, |
| 21 | + { name: 'Tom Becker', department: 'Engineering' }, |
| 22 | + { name: 'Yuki Sato', department: 'Engineering' }, |
| 23 | + { name: 'Daniel Kim', department: 'Finance' }, |
| 24 | + { name: 'Elena Popescu', department: 'Finance' }, |
| 25 | + { name: 'Grace Okafor', department: 'Finance' }, |
| 26 | + { name: 'Hugo Martin', department: 'Marketing' }, |
| 27 | + { name: 'Isabel Costa', department: 'Marketing' }, |
| 28 | + { name: 'Lena Fischer', department: 'Marketing' }, |
| 29 | + { name: 'Jonas Berg', department: 'Sales' }, |
| 30 | + { name: 'Omar Haddad', department: 'Sales' }, |
| 31 | + { name: 'Sofia Rossi', department: 'Sales' } |
| 32 | + ]; |
| 33 | + |
| 34 | + public selectedPeople = ['Ana Petrova', 'Marc Lee']; |
| 35 | + |
| 36 | + /* Merged over the combo's own settings, so the list still opens below the combo. |
| 37 | + A modal overlay dims the page behind the list, and a click outside closes it. */ |
17 | 38 | public overlaySettings: OverlaySettings = { |
18 | | - positionStrategy: new GlobalPositionStrategy({ openAnimation: scaleInCenter, closeAnimation: scaleOutCenter }), |
19 | 39 | modal: true, |
20 | 40 | closeOnOutsideClick: true |
21 | 41 | }; |
| 42 | + |
| 43 | + // Opens the list on load, so the sample shows the overlay right away. |
| 44 | + public ngAfterViewInit() { |
| 45 | + this.combo.open(); |
| 46 | + } |
22 | 47 | } |
0 commit comments