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


TypeScript ReflectiveInjector.resolve方法代码示例

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


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

示例1: open

  public open(modalInstance: SkyModalInstance, component: any, providers?: any[]) {
    let factory = this.resolver.resolveComponentFactory(component);
    let hostService = new SkyModalHostService();

    providers = providers || [];

    providers.push({
      provide: SkyModalHostService,
      useValue: hostService
    });

    let resolvedProviders = ReflectiveInjector.resolve(providers);

    let injector = ReflectiveInjector.fromResolvedProviders(resolvedProviders, this.injector);

    let modalComponentRef = this.target.createComponent(factory, undefined, injector);

    modalInstance.componentInstance = modalComponentRef.instance;

    function closeModal() {
      hostService.destroy();
      modalComponentRef.destroy();
    }

    hostService.close.subscribe((modalComponent: SkyModalComponent) => {
      closeModal();
    });

    modalInstance.setCloseCallback(() => {
      closeModal();
    });
  }
开发者ID:blackbaud-brandonstirnaman,项目名称:skyux2,代码行数:32,代码来源:modal-host.component.ts

示例2: async

  return async(): Promise<BootstrapResponse> => {

    try {
      deferredLog('info', 'Bootstrapping server');
      const resolvedProviders: ProviderType[] = await Promise.all(CORE_PROVIDERS.concat(providers));

      //initialize all bootstrappers (in order they need to be created)
      const resolvedBootstrappers: EntityBootstrapper[] = [
        new ModelBootstrapper,
        new ServiceBootstrapper,
        new MigrationBootstrapper,
        new SeederBootstrapper,
        new ControllerBootstrapper,
      ];

      const bootrapperProviders: any[] = resolvedBootstrappers.reduce((result: any[], bootstrapper: EntityBootstrapper) => {
        return result.concat(bootstrapper.getInjectableEntities());
      }, []);

      const mergedProviders = ReflectiveInjector.resolve(bootrapperProviders.concat(resolvedProviders));

      const injector = ReflectiveInjector.fromResolvedProviders(mergedProviders);

      logger = injector.get(Logger)
        .source('bootstrap');

      // iterate over any logs that have been deferred
      deferredLogs.forEach((log: DeferredLog) => {
        logger[log.level](...log.messages);
      });
      deferredLogs = []; //clear buffer

      // iterate over all of the resolved bootstrappers, invoking the bootstrap to initialize the
      // entities. iteration is completed in serial so that bootstrappers that depend on other
      // entities won't invoke until those other entities are finished intializing
      await resolvedBootstrappers.reduce(async(current: Promise<void>, next: EntityBootstrapper): Promise<void> => {

        await current;

        return Promise.resolve(next.setInjector(injector).invokeBootstrap());

      }, Promise.resolve()); //initial value
      // get vars for the bootstrapper
      const server: Server = injector.get(Server);

      let response = {injector, server, logger};

      if (afterBootstrap) {
        await afterBootstrap(response);
        // await Promise.resolve(afterBootstrap(response));
        return response;
      }

      return response;
    } catch (e) {
      handleBootstrapError(e, logger);
    }

  }
开发者ID:ubiquits,项目名称:ubiquits,代码行数:59,代码来源:bootstrap.ts

示例3:

 /**
  * Helper methods to add ComponentClass(like modal backdrop) with options
  * of type ComponentOptionsClass to element next to application root
  * or next to provided instance of view container
  * @param ComponentClass - @Component class
  * @param ComponentOptionsClass - options class
  * @param options - instance of options
  * @returns {ComponentRef<T>} - returns ComponentRef<T>
  */
 public appendNextToRoot<T>(ComponentClass:Type<T>,
                            ComponentOptionsClass:any,
                            options:any):ComponentRef<T> {
   let location = this.getRootViewContainerRef();
   let providers = ReflectiveInjector.resolve([
     {provide: ComponentOptionsClass, useValue: options}
   ]);
   return this.appendNextToLocation(ComponentClass, location, providers);
 }
开发者ID:jdelgadoalfonso,项目名称:ng2-bootstrap,代码行数:18,代码来源:components-helper.service.ts

示例4:

  /**
   * A helper function for derived classes to create backdrop & container
   * @param dialogRef
   * @param backdrop
   * @param container
   * @returns { backdropRef: ComponentRef<B>, containerRef: ComponentRef<C> }
   *
   * @deprecated use createBackdrop and createContainer instead
   */
  protected createModal<B, C>(dialogRef: DialogRef<any>, backdrop: Class<B>, container: Class<C>)
                                : { backdropRef: ComponentRef<B>, containerRef: ComponentRef<C> } {
    const b = ReflectiveInjector.resolve([{provide: DialogRef, useValue: dialogRef}]);

    return {
      backdropRef: dialogRef.overlayRef.instance.addComponent<B>(backdrop, b),
      containerRef: dialogRef.overlayRef.instance.addComponent<C>(container, b)
    };
  }
开发者ID:CaselIT,项目名称:angular2-modal,代码行数:18,代码来源:modal.ts

示例5: TooltipData

			this._cr.resolveComponent(TooltipComponent).then((cmpFactory: ComponentFactory<TooltipComponent>) => {
				// Create reflective injector to provide an instance of TooltipData 
				let providers = ReflectiveInjector.resolve([
					{ provide: TooltipData, useValue: new TooltipData(el, text, align) },
				]);
				let injector = ReflectiveInjector.fromResolvedProviders(providers, this.viewContainer.parentInjector);

				// Create the component, outputs a promise...
				return this.viewContainer.createComponent(cmpFactory, this.viewContainer.length, injector);
			}).then((cmpRef: ComponentRef<TooltipComponent>) => {
开发者ID:cviccaro,项目名称:jpa-admin,代码行数:10,代码来源:provider.ts

示例6: Provider

      .then((componentFactory:ComponentFactory<T>) => {
        const viewContainerRef = _viewContainerRef || this.getRootViewContainerRef();
        let bindings = ReflectiveInjector.resolve([
          new Provider(ComponentOptionsClass, {useValue: options})
        ]);
        const ctxInjector = viewContainerRef.parentInjector;

        const childInjector = Array.isArray(bindings) && bindings.length > 0 ?
          ReflectiveInjector.fromResolvedProviders(bindings, ctxInjector) : ctxInjector;
        return viewContainerRef.createComponent(componentFactory, viewContainerRef.length, childInjector);
      });
开发者ID:CardosoGit,项目名称:ng2-bootstrap,代码行数:11,代码来源:components-helper.service.ts

示例7: createBindings

function createBindings(config: OneButtonPresetData): ResolvedReflectiveBinding[] {
    config.buttons = [
        {
            cssClass: config.okBtnClass,
            caption: config.okBtn,
            onClick: (modalComponent: MessageModal, $event?: MouseEvent) =>
                modalComponent.dialog.close(true)
        }
    ];

    return ReflectiveInjector.resolve([
        provide(MessageModalContext, {useValue: config})
    ]);
}
开发者ID:andela-jmwangi,项目名称:angular2-modal,代码行数:14,代码来源:OneButtonPreset.ts

示例8: render

  render(dialog: DialogRef<any>, vcRef: ViewContainerRef): ComponentRef<ModalOverlay> {
    const b = ReflectiveInjector.resolve([
      { provide: DialogRef, useValue: dialog }
    ]);

    const cmpRef = createComponent(this._cr, ModalOverlay, vcRef, b);

    if (dialog.inElement) {
      vcRef.element.nativeElement.appendChild(cmpRef.location.nativeElement);
    } else {
      document.body.appendChild(cmpRef.location.nativeElement);
    }

    return cmpRef;
  }
开发者ID:CaselIT,项目名称:angular2-modal,代码行数:15,代码来源:dom-modal-renderer.ts

示例9: open

  public open(modalInstance: SkyModalInstance, component: any, config?: IConfig) {
    let params: IConfig = Object.assign({}, config);
    let factory = this.resolver.resolveComponentFactory(component);
    let hostService = new SkyModalHostService();
    let adapter = this.adapter;

    params.providers.push({
      provide: SkyModalHostService,
      useValue: hostService
    });
    params.providers.push({
      provide: SkyModalConfiguation,
      useValue: params
    });

    adapter.setPageScroll(SkyModalHostService.openModalCount > 0);

    let providers = params.providers /* istanbul ignore next */ || [];
    let resolvedProviders = ReflectiveInjector.resolve(providers);
    let injector = ReflectiveInjector.fromResolvedProviders(resolvedProviders, this.injector);
    let modalComponentRef = this.target.createComponent(factory, undefined, injector);

    modalInstance.componentInstance = modalComponentRef.instance;

    function closeModal() {
      hostService.destroy();
      adapter.setPageScroll(SkyModalHostService.openModalCount > 0);
      modalComponentRef.destroy();
    }

    hostService.close.subscribe((modalComponent: SkyModalComponent) => {
      closeModal();
    });

    modalInstance.setCloseCallback(() => {
      closeModal();
    });
  }
开发者ID:Blackbaud-DanHamlin,项目名称:skyux2,代码行数:38,代码来源:modal-host.component.ts


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