2016-01-24 20:02:02 +03:00
|
|
|
'use strict';
|
|
|
|
|
2016-01-24 22:27:15 +03:00
|
|
|
import {Component, View, ElementRef} from 'angular2/core';
|
2016-01-24 20:02:02 +03:00
|
|
|
import {CORE_DIRECTIVES} from 'angular2/common';
|
|
|
|
import JsonSchema from './json-schema';
|
|
|
|
import {DynamicComponentLoader} from 'angular2/src/core/linker/dynamic_component_loader';
|
2016-01-24 22:27:15 +03:00
|
|
|
import OptionsManager from '../../options';
|
2016-01-24 20:02:02 +03:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'json-schema-lazy',
|
|
|
|
inputs: ['pointer']
|
|
|
|
})
|
|
|
|
@View({
|
|
|
|
template: '',
|
|
|
|
directives: [CORE_DIRECTIVES]
|
|
|
|
})
|
|
|
|
export default class JsonSchemaLazy {
|
|
|
|
|
|
|
|
constructor(elementRef, dcl) {
|
|
|
|
this.elementRef = elementRef;
|
|
|
|
this.dcl = dcl;
|
|
|
|
}
|
|
|
|
|
|
|
|
load() {
|
2016-01-24 22:27:15 +03:00
|
|
|
if (OptionsManager.instance().options.disableLazySchemas) return;
|
|
|
|
if (this.loaded) return;
|
|
|
|
if (this.pointer) {
|
|
|
|
this.dcl.loadNextToLocation(JsonSchema, this.elementRef).then((compRef) => {
|
|
|
|
compRef.instance.pointer = this.pointer;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
this.loaded = true;
|
2016-01-24 20:02:02 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
JsonSchemaLazy.parameters = [[ElementRef], [DynamicComponentLoader]];
|