@@ -99,7 +99,8 @@ describe('igxSelect', () => {
9999 IgxSelectReactiveFormComponent ,
100100 IgxSelectTemplateFormComponent ,
101101 IgxSelectHeaderFooterComponent ,
102- IgxSelectCDRComponent
102+ IgxSelectCDRComponent ,
103+ IgxSelectWithIdComponent
103104 ]
104105 } ) . compileComponents ( ) ;
105106 } ) ) ;
@@ -532,6 +533,21 @@ describe('igxSelect', () => {
532533 expect ( dummyInput ) . toEqual ( document . activeElement ) ;
533534 expect ( select . collapsed ) . toBeFalsy ( ) ;
534535 } ) ) ;
536+
537+ it ( 'should set the id attribute when using property binding' , ( ) => {
538+ fixture = TestBed . createComponent ( IgxSelectWithIdComponent ) ;
539+ fixture . detectChanges ( ) ;
540+
541+ select = fixture . componentInstance . select ;
542+ fixture . detectChanges ( ) ;
543+
544+ const selectElement = fixture . debugElement . query ( By . css ( 'igx-select' ) ) . nativeElement ;
545+ fixture . detectChanges ( ) ;
546+
547+ expect ( select ) . toBeTruthy ( ) ;
548+ expect ( select . id ) . toEqual ( "id1" ) ;
549+ expect ( selectElement . getAttribute ( 'id' ) ) . toBe ( 'id1' ) ;
550+ } ) ;
535551 } ) ;
536552
537553 describe ( 'Form tests: ' , ( ) => {
@@ -3107,3 +3123,21 @@ class IgxSelectCDRComponent {
31073123 { field : 'ContactName' , type : 'string' }
31083124 ] ;
31093125}
3126+
3127+ @Component ( {
3128+ template : `
3129+ <igx-select [id]="'id1'">
3130+ <igx-select-item *ngFor="let item of items" [value]="item">
3131+ {{item}}
3132+ </igx-select-item>
3133+ </igx-select>
3134+ ` ,
3135+ standalone : true ,
3136+ imports : [ NgIf , IgxSelectComponent , IgxSelectItemComponent , IgxLabelDirective , NgFor ]
3137+ } )
3138+ class IgxSelectWithIdComponent {
3139+ @ViewChild ( IgxSelectComponent , { read : IgxSelectComponent , static : true } )
3140+ public select : IgxSelectComponent ;
3141+
3142+ public items : string [ ] = [ 'Item 1' , 'Item 2' , 'Item 3' , 'Item 4' , 'Item 5' ] ;
3143+ }
0 commit comments