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

View File

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