Propagate external options

This commit is contained in:
Roman Hotsiy 2016-08-29 07:30:49 +03:00
parent 50f65f7cfd
commit 27197ffb46
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
2 changed files with 7 additions and 4 deletions

View File

@ -17,8 +17,9 @@ import { OptionsService, RedocEventsService } from '../../services/index';
}) })
export class Redoc extends BaseComponent implements AfterViewInit { export class Redoc extends BaseComponent implements AfterViewInit {
static appRef: ComponentRef<any>; static appRef: ComponentRef<any>;
static _preOptions: any;
options: any; public options: any;
private element: any; private element: any;
@ -51,6 +52,8 @@ export class Redoc extends BaseComponent implements AfterViewInit {
constructor(specMgr: SpecManager, optionsMgr:OptionsService, elementRef:ElementRef, constructor(specMgr: SpecManager, optionsMgr:OptionsService, elementRef:ElementRef,
public events:RedocEventsService) { public events:RedocEventsService) {
super(specMgr); super(specMgr);
// merge options passed before init
optionsMgr.options = Redoc._preOptions;
this.element = elementRef.nativeElement; this.element = elementRef.nativeElement;
//parse options (top level component doesn't support inputs) //parse options (top level component doesn't support inputs)
optionsMgr.parseOptions( this.element ); optionsMgr.parseOptions( this.element );

View File

@ -20,9 +20,9 @@ export function init(specUrl:string, options?) {
if (moduleRef) { if (moduleRef) {
destroy(); destroy();
} }
//
// optionsService.options = options; Redoc._preOptions = options;
// optionsService.options.specUrl = optionsService.options.specUrl || specUrl; options.specUrl = options.specUrl || specUrl;
Redoc.showLoadingAnimation(); Redoc.showLoadingAnimation();
return SpecManager.instance().load(specUrl) return SpecManager.instance().load(specUrl)