How to use the angular2-universal.serializeDocument function in angular2-universal

To help you get started, we’ve selected a few angular2-universal examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github barbatus / angular2-meteor-universal / build / bootloader.js View on Github external
.then(function (config) {
            var doc = config.appRef.injector.get(platform_browser_1.DOCUMENT);
            var html = angular2_universal_1.serializeDocument(doc);
            var meteorApp = config.appRef.injector.get(angular2_meteor_1.MeteorApp);
            var logger = config.appRef.injector.get(logger_1.Logger);
            var size = (html.length * 2 / 1024) >> 0;
            logger.debug("page has been serialized (size: " + size + "kb)");
            if (size > options.pageSizeLimitKb) {
                logger.warn("page (size: " + size + "kb) exceeded limit size " + options.pageSizeLimitKb + "kb");
            }
            meteorApp.onStable(function () {
                config.appRef.dispose();
                logger.debug('page has been disposed');
            });
            return html;
        })
            .then(function (html) { return future.return(html); })
github barbatus / angular2-meteor-universal / modules / bootloader.ts View on Github external
.then(config => {
      let doc = config.appRef.injector.get(DOCUMENT);
      let html = serializeDocument(doc);
      let meteorApp = config.appRef.injector.get(MeteorApp);
      let logger = config.appRef.injector.get(Logger);
      let size = (html.length * 2 / 1024) >> 0;
      logger.debug(`page has been serialized (size: ${size}kb)`);
      if (size > options.pageSizeLimitKb) {
        logger.warn(`page (size: ${size}kb) exceeded limit size ${options.pageSizeLimitKb}kb`);
      }
      meteorApp.onStable(() => {
        config.appRef.dispose();
        logger.debug('page has been disposed');
      });
      return html;
    })
    .then(html => future.return(html))
github barbatus / angular2-meteor-universal / build / bootloader.js View on Github external
Bootloader.prototype.serialize = function (component, providers, options) {
        if (!options.on) {
            var doc = this.createDoc(component);
            var html = angular2_universal_1.serializeDocument(doc);
            return html;
        }
        var future = new Future;
        this.bootstrap(component, providers, options).then(function (config) {
            return utils_1.waitRender(config.compRef, options.renderLimitMs)
                .then(function (stable) { return config; });
        })
            .then(function (config) {
            var preboot = _.extend({ debug: options.debug }, options.preboot);
            var prebootCode = angular2_universal_1.createPrebootCode(component, preboot);
            return prebootCode
                .then(function (code) {
                var el = config.compRef.location.nativeElement;
                var script = angular2_universal_1.parseFragment(code);
                var prebootEl = DOM.createElement('div');
                DOM.setInnerHTML(prebootEl, code);
github barbatus / angular2-meteor-universal / modules / bootloader.ts View on Github external
serialize(component: Type,
            providers: Providers,
            options: ServerOptions): string {

    if (!options.on) {
      let doc = this.createDoc(component);
      let html = serializeDocument(doc);
      return html;
    }

    let future = new Future;
    this.bootstrap(component, providers, options).then(config => {
      return waitRender(config.compRef, options.renderLimitMs)
        .then(stable => config);
    })
    .then(config => {
      let preboot = _.extend({ debug: options.debug }, options.preboot);
      let prebootCode = createPrebootCode(component, preboot);

      return prebootCode
        .then(code => {
          let el = config.compRef.location.nativeElement;
          let script = parseFragment(code);