@@ -98,7 +98,8 @@ describe('igxSelect', () => {
9898 IgxSelectReactiveFormComponent ,
9999 IgxSelectTemplateFormComponent ,
100100 IgxSelectHeaderFooterComponent ,
101- IgxSelectCDRComponent
101+ IgxSelectCDRComponent ,
102+ IgxSelectWithIdComponent
102103 ]
103104 } ) . compileComponents ( ) ;
104105 } ) ) ;
@@ -515,6 +516,21 @@ describe('igxSelect', () => {
515516 expect ( dummyInput ) . toEqual ( document . activeElement ) ;
516517 expect ( select . collapsed ) . toBeFalsy ( ) ;
517518 } ) ) ;
519+
520+ it ( 'should set the id attribute when using property binding' , ( ) => {
521+ fixture = TestBed . createComponent ( IgxSelectWithIdComponent ) ;
522+ fixture . detectChanges ( ) ;
523+
524+ select = fixture . componentInstance . select ;
525+ fixture . detectChanges ( ) ;
526+
527+ const selectElement = fixture . debugElement . query ( By . css ( 'igx-select' ) ) . nativeElement ;
528+ fixture . detectChanges ( ) ;
529+
530+ expect ( select ) . toBeTruthy ( ) ;
531+ expect ( select . id ) . toEqual ( "id1" ) ;
532+ expect ( selectElement . getAttribute ( 'id' ) ) . toBe ( 'id1' ) ;
533+ } ) ;
518534 } ) ;
519535
520536 describe ( 'Form tests: ' , ( ) => {
@@ -3091,3 +3107,21 @@ class IgxSelectCDRComponent {
30913107 { field : 'ContactName' , type : 'string' }
30923108 ] ;
30933109}
3110+
3111+ @Component ( {
3112+ template : `
3113+ <igx-select [id]="'id1'">
3114+ <igx-select-item *ngFor="let item of items" [value]="item">
3115+ {{item}}
3116+ </igx-select-item>
3117+ </igx-select>
3118+ ` ,
3119+ standalone : true ,
3120+ imports : [ NgIf , IgxSelectComponent , IgxSelectItemComponent , IgxLabelDirective , NgFor ]
3121+ } )
3122+ class IgxSelectWithIdComponent {
3123+ @ViewChild ( IgxSelectComponent , { read : IgxSelectComponent , static : true } )
3124+ public select : IgxSelectComponent ;
3125+
3126+ public items : string [ ] = [ 'Item 1' , 'Item 2' , 'Item 3' , 'Item 4' , 'Item 5' ] ;
3127+ }
0 commit comments