@@ -30,6 +30,7 @@ let DxTestWidget = DxButton['inherit']({
3030 _render ( ) {
3131 this . callBase ( ) ;
3232 this . element ( ) [ 0 ] . classList . add ( 'dx-test-widget' ) ;
33+ this . option ( 'testCalculatedOption' , 'changed' ) ;
3334 }
3435} ) ;
3536
@@ -46,12 +47,20 @@ export class DxTestWidgetComponent extends DxComponent implements AfterViewInit,
4647 set testOption ( value : any ) {
4748 this . _setOption ( 'testOption' , value ) ;
4849 } ;
50+ @Input ( )
51+ get testCalculatedOption ( ) : any {
52+ return this . _getOption ( 'testCalculatedOption' ) ;
53+ }
54+ set testCalculatedOption ( value : any ) {
55+ this . _setOption ( 'testCalculatedOption' , value ) ;
56+ } ;
4957
5058 @Output ( ) onOptionChanged = new EventEmitter < any > ( ) ;
5159 @Output ( ) onInitialized = new EventEmitter < any > ( ) ;
5260 @Output ( ) onDisposing = new EventEmitter < any > ( ) ;
5361 @Output ( ) onContentReady = new EventEmitter < any > ( ) ;
5462 @Output ( ) testOptionChange = new EventEmitter < any > ( ) ;
63+ @Output ( ) testCalculatedOptionChange = new EventEmitter < any > ( ) ;
5564
5665 constructor ( elementRef : ElementRef , ngZone : NgZone , templateHost : DxTemplateHost , _watcherHelper : WatcherHelper ) {
5766 super ( elementRef , ngZone , templateHost , _watcherHelper ) ;
@@ -61,7 +70,8 @@ export class DxTestWidgetComponent extends DxComponent implements AfterViewInit,
6170 { subscribe : 'initialized' , emit : 'onInitialized' } ,
6271 { subscribe : 'disposing' , emit : 'onDisposing' } ,
6372 { subscribe : 'contentReady' , emit : 'onContentReady' } ,
64- { emit : 'testOptionChange' }
73+ { emit : 'testOptionChange' } ,
74+ { emit : 'testCalculatedOptionChange' }
6575 ] ) ;
6676 }
6777
@@ -85,6 +95,8 @@ export class DxTestWidgetComponent extends DxComponent implements AfterViewInit,
8595export class TestContainerComponent {
8696 visible = true ;
8797 testOption : string ;
98+ testCalculatedOption = 'initial' ;
99+
88100 @ViewChildren ( DxTestWidgetComponent ) innerWidgets : QueryList < DxTestWidgetComponent > ;
89101 testMethod ( ) {
90102 }
@@ -349,4 +361,18 @@ describe('DevExtreme Angular widget', () => {
349361 instance . fireEvent ( 'unknownEvent' ) ;
350362 } ) ) ;
351363
364+ it ( 'should detect option changes when option was changed on DX widget creation (T527596)' , async ( ( ) => {
365+ TestBed . overrideComponent ( TestContainerComponent , {
366+ set : {
367+ template : '<dx-test-widget [(testCalculatedOption)]="testCalculatedOption"></dx-test-widget>'
368+ }
369+ } ) ;
370+
371+ let fixture = TestBed . createComponent ( TestContainerComponent ) ;
372+ fixture . detectChanges ( ) ;
373+
374+ expect ( getWidget ( fixture ) . option ( 'testCalculatedOption' ) ) . toBe ( 'changed' ) ;
375+ expect ( fixture . componentInstance . testCalculatedOption ) . toBe ( 'changed' ) ;
376+ } ) ) ;
377+
352378 } ) ;
0 commit comments