@@ -13,9 +13,12 @@ import {
1313 ViewChild ,
1414 Output ,
1515 EventEmitter ,
16+ ContentChild ,
17+ AfterContentInit ,
1618} from '@angular/core' ;
1719import { IDropdownProps , IDropdownOption , IDropdown } from 'office-ui-fabric-react/lib/Dropdown' ;
1820import { ISelectableDroppableTextProps , ISelectableOption } from 'office-ui-fabric-react' ;
21+ import { DropdownOptionsDirective } from './directives/dropdown-options.directive' ;
1922
2023@Component ( {
2124 selector : 'fab-dropdown' ,
@@ -61,8 +64,9 @@ import { ISelectableDroppableTextProps, ISelectableOption } from 'office-ui-fabr
6164 styles : [ 'react-renderer' ] ,
6265 changeDetection : ChangeDetectionStrategy . OnPush ,
6366} )
64- export class FabDropdownComponent extends ReactWrapperComponent < IDropdownProps > implements OnInit {
67+ export class FabDropdownComponent extends ReactWrapperComponent < IDropdownProps > implements OnInit , AfterContentInit {
6568 @ViewChild ( 'reactNode' ) protected reactNodeRef : ElementRef ;
69+ @ContentChild ( DropdownOptionsDirective ) readonly dropdownOptionsDirective ?: DropdownOptionsDirective ;
6670
6771 @Input ( ) componentRef ?: IDropdownProps [ 'componentRef' ] ;
6872 @Input ( ) label ?: IDropdownProps [ 'label' ] ;
@@ -135,6 +139,13 @@ export class FabDropdownComponent extends ReactWrapperComponent<IDropdownProps>
135139 this . onRenderCaretDown = this . createRenderPropHandler ( this . renderCaretDown ) ;
136140 }
137141
142+ ngAfterContentInit ( ) {
143+ if ( this . dropdownOptionsDirective ) {
144+ this . _initDirective ( this . dropdownOptionsDirective ) ;
145+ }
146+ super . ngAfterContentInit ( ) ;
147+ }
148+
138149 onChangeHandler ( event : React . FormEvent < HTMLDivElement > , option ?: IDropdownOption , index ?: number ) {
139150 this . onChange . emit ( {
140151 event : event && event . nativeEvent ,
@@ -146,4 +157,9 @@ export class FabDropdownComponent extends ReactWrapperComponent<IDropdownProps>
146157 onDismissHandler ( ) {
147158 this . onDismiss . emit ( ) ;
148159 }
160+
161+ private _initDirective ( directive : DropdownOptionsDirective ) {
162+ this . options = directive . items ;
163+ this . markForCheck ( ) ;
164+ }
149165}
0 commit comments