当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript PlatformRef.bootstrapModule方法代码示例

本文整理汇总了TypeScript中@angular/core.PlatformRef.bootstrapModule方法的典型用法代码示例。如果您正苦于以下问题:TypeScript PlatformRef.bootstrapModule方法的具体用法?TypeScript PlatformRef.bootstrapModule怎么用?TypeScript PlatformRef.bootstrapModule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@angular/core.PlatformRef的用法示例。


在下文中一共展示了PlatformRef.bootstrapModule方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: bootstrap

export function bootstrap(platform: PlatformRef, Ng2Module: Type<{}>, element: Element, modules: string[]) {
  // We bootstrap the Angular module first; then when it is ready (async)
  // We bootstrap the AngularJS module on the bootstrap element
  return platform.bootstrapModule(Ng2Module).then(ref => {
    const upgrade = ref.injector.get(UpgradeModule) as UpgradeModule;
    upgrade.bootstrap(element, modules);
    return upgrade;
  });
}
开发者ID:jtk54,项目名称:deck,代码行数:9,代码来源:helpers.ts

示例2: bootstrap

export function bootstrap(
    platform: PlatformRef, Ng2Module: Type<{}>, element: Element, ng1Module: angular.IModule) {
  // We bootstrap the Angular 2 module first; then when it is ready (async)
  // We bootstrap the Angular 1 module on the bootstrap element
  return platform.bootstrapModule(Ng2Module).then(ref => {
    var upgrade = ref.injector.get(UpgradeModule) as UpgradeModule;
    upgrade.bootstrap(element, [ng1Module.name]);
    return upgrade;
  });
}
开发者ID:efidiles,项目名称:angular,代码行数:10,代码来源:test_helpers.ts

示例3: bootstrap

export function bootstrap(
    platform: PlatformRef, Ng2Module: Type<{}>, element: Element, ng1Module: angular.IModule) {
  // We bootstrap the Angular module first; then when it is ready (async) we bootstrap the AngularJS
  // module on the bootstrap element (also ensuring that AngularJS errors will fail the test).
  return platform.bootstrapModule(Ng2Module).then(ref => {
    const upgrade = ref.injector.get(UpgradeModule);
    const failHardModule: any = ($provide: angular.IProvideService) => {
      $provide.value('$exceptionHandler', (err: any) => { throw err; });
    };
    upgrade.bootstrap(element, [failHardModule, ng1Module.name]);
    return upgrade;
  });
}
开发者ID:DanielKucal,项目名称:angular,代码行数:13,代码来源:test_helpers.ts

示例4: bootstrap

export function bootstrap(
    platform: PlatformRef, Ng2Module: Type<{}>, element: Element, ng1Module: angular.IModule) {
  // We bootstrap the Angular module first; then when it is ready (async) we bootstrap the AngularJS
  // module on the bootstrap element (also ensuring that AngularJS errors will fail the test).
  return platform.bootstrapModule(Ng2Module).then(ref => {
    const ngZone = ref.injector.get<NgZone>(NgZone);
    const upgrade = ref.injector.get(UpgradeModule);
    const failHardModule: any = ($provide: angular.IProvideService) => {
      $provide.value($EXCEPTION_HANDLER, (err: any) => { throw err; });
    };

    // The `bootstrap()` helper is used for convenience in tests, so that we don't have to inject
    // and call `upgrade.bootstrap()` on every Angular module.
    // In order to closer emulate what happens in real application, ensure AngularJS is bootstrapped
    // inside the Angular zone.
    //
    ngZone.run(() => upgrade.bootstrap(element, [failHardModule, ng1Module.name]));

    return upgrade;
  });
}
开发者ID:cyrilletuzi,项目名称:angular,代码行数:21,代码来源:test_helpers.ts

示例5: async

  WebAppInternals.registerBoilerplateDataCallback('angular', async (request, data) => {

    let document,
      platformRef: PlatformRef;
    // Handle Angular's error, but do not prevent client bootstrap
    try {


      document = `
        <html>
          <head>
              <base href="/">
          </head>
          <body>
              <app></app>
          </body>
        </html>
      `;

      // Integrate Angular's router with Meteor
      const url = request.url;

      // Get rendered document
      platformRef = platformDynamicServer([
        {
          provide: INITIAL_CONFIG,
          useValue: {
            // Initial document
            document,
            url
          }
        }
      ]);

      const appModuleRef = await platformRef.bootstrapModule(ServerAppModule, {
        ngZone: 'noop',
        providers: [
          {
            provide: ResourceLoader,
            useValue: {
              get: Assets.getText
            },
            deps: []
          }
        ]
      });

      const applicationRef: ApplicationRef = appModuleRef.injector.get(ApplicationRef);

      await applicationRef.isStable.pipe(
        first(isStable => isStable == true)
      ).toPromise();

      applicationRef.tick();

      // Run any BEFORE_APP_SERIALIZED callbacks just before rendering to string.
      const callbacks = appModuleRef.injector.get(BEFORE_APP_SERIALIZED, null);
      if (callbacks) {
        for (const callback of callbacks) {
          try {
            callback();
          } catch (e) {
            // Ignore exceptions.
            console.warn('Ignoring BEFORE_APP_SERIALIZED Exception: ', e);
          }
        }
      }

      const platformState: PlatformState = appModuleRef.injector.get(PlatformState);

      document = platformState.renderToString();

    } catch (e) {

      // Write errors to console
      console.error('Angular SSR Error: ' + e.stack || e);

    } finally {

      //Make sure platform is destroyed before rendering

      if (platformRef) {
        platformRef.destroy();
      }
      const head = HEAD_REGEX.exec(document)[1];
      data.dynamicHead = head;
      const body = BODY_REGEX.exec(document)[1];
      data.dynamicBody = body;

    }
  })
开发者ID:Urigo,项目名称:angular-meteor,代码行数:91,代码来源:main.ts


注:本文中的@angular/core.PlatformRef.bootstrapModule方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。