File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -744,7 +744,10 @@ export class IgComboComponent extends IgControlBase<IgCombo> implements ControlV
744744 this . _dataSource = jQuery . extend ( true , [ ] , this . _config . dataSource ) ;
745745 if ( this . _changes ) {
746746 this . _changes . forEachAddedItem ( r => element . data ( "igCombo" ) . dataBind ( ) ) ;
747- this . _changes . forEachRemovedItem ( r => element . data ( "igCombo" ) . dataBind ( ) )
747+ this . _changes . forEachRemovedItem ( r => element . data ( "igCombo" ) . dataBind ( ) ) ;
748+ if ( this . model && this . model . value ) {
749+ this . writeValue ( this . model . value ) ;
750+ }
748751 }
749752 }
750753
Original file line number Diff line number Diff line change @@ -94,6 +94,29 @@ export function main() {
9494 } , 10 ) ;
9595 } ) ;
9696 } ) ;
97+
98+ it ( 'should apply the model if there is a new data assigned' , ( done ) => {
99+ var template = '<div><ig-combo [(widgetId)]="comboID" [valueKey]="\'ProductID\'" [textKey]="\'ProductName\'" [changeDetectionInterval]="cdi" [(dataSource)]="data" [(ngModel)]="combo.value1"></ig-combo></div>' ;
100+ TestBed . overrideComponent ( TestComponent , {
101+ set : {
102+ template : template
103+ }
104+ } ) ;
105+ TestBed . compileComponents ( ) . then ( ( ) => {
106+ let fixture = TestBed . createComponent ( TestComponent ) ;
107+ fixture . detectChanges ( ) ;
108+ fixture . componentInstance . data = fixture . componentInstance . northwind ;
109+
110+ setTimeout ( function ( ) {
111+ fixture . detectChanges ( ) ;
112+
113+ expect ( $ ( "#combo1" ) . igCombo ( "value" ) ) . toBe ( fixture . componentInstance . combo . value1 ) ;
114+ expect ( $ ( "#combo1" ) . val ( ) )
115+ . toBe ( fixture . componentInstance . northwind [ fixture . componentInstance . combo . value1 - 1 ] . ProductName ) ;
116+ done ( ) ;
117+ } , 10 ) ;
118+ } ) ;
119+ } ) ;
97120 } ) ;
98121}
99122
@@ -107,6 +130,7 @@ class TestComponent {
107130 public combo : any ;
108131 private comboID : string
109132 private cdi = 10 ;
133+ public data : Array < any > = [ ] ;
110134 @ViewChild ( Infragistics . IgComboComponent ) public viewChild : Infragistics . IgComboComponent ;
111135
112136 constructor ( ) {
You can’t perform that action at this time.
0 commit comments