File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed
Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -703,13 +703,15 @@ export class IgComboComponent extends IgControlBase<IgCombo> implements ControlV
703703 super . ngOnInit ( ) ;
704704 jQuery ( this . _el ) . on ( this . _widgetName . toLowerCase ( ) + "selectionchanged" , function ( evt , ui ) {
705705 var items = ui . items ;
706- if ( items . length > 0 ) {
706+ if ( items . length > 0 && that . _model ) {
707707 that . _model . viewToModelUpdate ( items [ 0 ] . data [ that . _config . valueKey ] ) ;
708708 }
709709 } ) ;
710710 this . _dataSource = jQuery . extend ( true , [ ] , this . _config . dataSource ) ;
711711 //manually call writeValue, because the LifeCycle has been changed and writeValue is executed before ngOnInit
712- this . writeValue ( this . _model . value ) ;
712+ if ( this . _model ) {
713+ this . writeValue ( this . _model . value ) ;
714+ }
713715 }
714716 writeValue ( value ) {
715717 if ( ! ! jQuery ( this . _el ) . data ( this . _widgetName ) ) {
@@ -740,7 +742,7 @@ export class IgComboComponent extends IgControlBase<IgCombo> implements ControlV
740742
741743 //check for changes in collection
742744 this . _changes = this . _differ . diff ( this . _config . dataSource ) ;
743- if ( this . _config . dataSource . length !== this . _dataSource . length ) {
745+ if ( this . _config . dataSource && this . _config . dataSource . length !== this . _dataSource . length ) {
744746 this . _dataSource = jQuery . extend ( true , [ ] , this . _config . dataSource ) ;
745747 if ( this . _changes ) {
746748 this . _changes . forEachAddedItem ( r => element . data ( "igCombo" ) . dataBind ( ) ) ;
Original file line number Diff line number Diff line change @@ -31,6 +31,22 @@ export function main() {
3131 } ) ;
3232 } ) ;
3333
34+ it ( 'should initialize ig-combo without ngModel' , ( done ) => {
35+ var template = '<div><ig-combo [(widgetId)]="comboID" [(options)]="options" [changeDetectionInterval]="cdi"></ig-combo></div>' ;
36+ TestBed . overrideComponent ( TestComponent , {
37+ set : {
38+ template : template
39+ }
40+ } ) ;
41+ TestBed . compileComponents ( ) . then ( ( ) => {
42+ let fixture = TestBed . createComponent ( TestComponent ) ;
43+ fixture . detectChanges ( ) ;
44+ expect ( fixture . debugElement . componentInstance . viewChild instanceof Infragistics . IgComboComponent )
45+ . toBe ( true ) ;
46+ done ( ) ;
47+ } ) ;
48+ } ) ;
49+
3450 it ( 'should be updated correctly if the ngModel value is updated' , ( done ) => {
3551 var template = '<div><ig-combo [(widgetId)]="comboID" [(options)]="options" [changeDetectionInterval]="cdi" [(ngModel)]="combo.value1"></ig-combo></div>' ;
3652 TestBed . overrideComponent ( TestComponent , {
You can’t perform that action at this time.
0 commit comments