當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript core.ComponentResolver類代碼示例

本文整理匯總了TypeScript中@angular/core.ComponentResolver的典型用法代碼示例。如果您正苦於以下問題:TypeScript ComponentResolver類的具體用法?TypeScript ComponentResolver怎麽用?TypeScript ComponentResolver使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ComponentResolver類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: render

    render(type: Type,
           viewContainer: ViewContainerRef,
           bindings: ResolvedReflectiveProvider[],
           dialog: DialogRef<any>): Promise<DialogRef<any>> {
        return this._cr.resolveComponent(type)
            .then(cmpFactory => {
                const ctxInjector = viewContainer.parentInjector;
                const childInjector = Array.isArray(bindings) && bindings.length > 0 ?
                    ReflectiveInjector.fromResolvedProviders(bindings, ctxInjector) : ctxInjector;
                return viewContainer.createComponent(cmpFactory, viewContainer.length, childInjector);
            })
            .then((cmpRef: any) => {
                if (dialog.inElement) {
                    this._renderer.invokeElementMethod(
                        viewContainer.element.nativeElement,
                        'appendChild',
                        [cmpRef.hostView.rootNodes[0]]
                    );
                } else {
                    document.body.appendChild(cmpRef.hostView.rootNodes[0]);
                }

                dialog.destroy = () => cmpRef.destroy();

                return dialog;
            });
    }
開發者ID:Shawn9999,項目名稱:angular2-modal,代碼行數:27,代碼來源:dom-modal-renderer.ts

示例2: render

  render(type: Type,
         viewContainer: ViewContainerRef,
         bindings: ResolvedReflectiveProvider[],
         dialog: DialogRef<any>): Promise<DialogRef<any>> {

    return this._cr.resolveComponent(type)
      .then(cmpFactory => {
        const ctxInjector = viewContainer.parentInjector;
        const childInjector = Array.isArray(bindings) && bindings.length > 0 ?
          ReflectiveInjector.fromResolvedProviders(bindings, ctxInjector) : ctxInjector;
        return viewContainer.createComponent(cmpFactory, viewContainer.length, childInjector);
      })
      .then((cmpRef: ComponentRef<any>) => {
        if (dialog.inElement) {
          viewContainer.element.nativeElement.appendChild(cmpRef.location.nativeElement);
        } else {
          document.body.appendChild(cmpRef.location.nativeElement);
        }

        dialog.onDestroy.subscribe( () => {
          if (typeof cmpRef.instance.canDestroy === 'function') {
            cmpRef.instance.canDestroy().then ( () => cmpRef.destroy() );
          } else {
            cmpRef.destroy();
          }
        });

        return dialog;
      });
  }
開發者ID:Anand024,項目名稱:angular2-modal,代碼行數:30,代碼來源:dom-modal-renderer.ts

示例3: ngOnInit

    public ngOnInit() {
        // just init the entity for this example
        this.entity = {
            description: "The description of the user instance, passed as (shared) reference"
        };


        // dynamic template built (
        var template = this.customComponentBuilder
            .CreateTemplate();

        // now we get built component, just to load it
        var dynamicComponent = this.customComponentBuilder
            .CreateComponent(template, FORM_DIRECTIVES);

        // we have a component and its target
        this.componentResolver
            .resolveComponent(dynamicComponent)
            .then((factory: ComponentFactory<IHaveDynamicData>) => {
                // Instantiates a single {@link Component} and inserts its Host View
                //   into this container at the specified `index`
                let dynamicComponent = this.dynamicComponentTarget.createComponent(factory, 0);

                // and here we have access to our dynamic component
                let component: IHaveDynamicData = dynamicComponent.instance;

                component.name = "The name passed to component as a value";
                component.entity = this.entity;
            });
    }
開發者ID:DavyDuDu,項目名稱:ng2Boilerplate,代碼行數:30,代碼來源:dynamic.component.holder.ts

示例4:

            .then(m => {
				//console.debug(' resolve Compnent :' + eval('m.' + compName));
				cr.resolveComponent(eval('m.' + compName)).then(factory => {
					//console.debug('callback '+factory);
					callback(vcr.createComponent(factory, 0));
				});
			})
開發者ID:ngtaeut,項目名稱:angular,代碼行數:7,代碼來源:routeutil.service.ts

示例5: updateComponent

 private updateComponent(transition: boolean = false) {
     if (transition) {
         this.host.clear();
     }
     this.resolver
         .resolveComponent(this.getStage())
         .then((f) => this.initComponent(f));
 }
開發者ID:soates,項目名稱:workflows,代碼行數:8,代碼來源:workflow-host.ts

示例6: createPlaceholder

 private createPlaceholder() {
     this.cmpResolver.resolveComponent(NgGridPlaceholder)
         .then((factory:ComponentFactory) => {
             this.placeholder = factory
                 .create(this.viewContainer.injector, undefined, this.window.document.body)
                 .instance;
         });
 }
開發者ID:Catalysts,項目名稱:angular2-grid,代碼行數:8,代碼來源:GridPlaceholderService.ts

示例7: instanciate

 /**
  *
  * @param componentType
  * @param viewContainer
  * @param injector
  *
  * @return {null}
  */
 public instanciate(componentType : Type, viewContainer : ViewContainerRef, injector : Injector = null) : Promise<ComponentRef<any>> {
     let componentRef;
     return this.componentResolver.resolveComponent(componentType).then(factory => {
          componentRef = viewContainer.createComponent(factory, viewContainer.length, injector || viewContainer.parentInjector);
     }).then(() => {
         return componentRef;
     });
 }
開發者ID:wayofspark,項目名稱:ng2-sandbox,代碼行數:16,代碼來源:ComponentUtils.ts

示例8:

			(resolve, reject) => {
				let componentClass = this.registry.getWidgetType(type);
				this.resolver.resolveComponent(componentClass).then(
					componentFactory => {
						let component = container.createComponent(componentFactory);
						resolve(component);
					}
				);
			}
開發者ID:un33k,項目名稱:angular2-schema-form,代碼行數:9,代碼來源:widgetfactory.ts

示例9: ngOnInit

  ngOnInit() {
    this.componentResolver.resolveComponent(Item1Component).then(factory => {
      // console.log(this.vs);
      let res = this.vc.createComponent(factory);
      //res.instance.setCoordinates(coordinates.first, coordinates.second);
    });


  }
開發者ID:HNAmine,項目名稱:LoadDynamicallyComponent,代碼行數:9,代碼來源:tower.ts

示例10:

 _loadTreeNodeContent() {
   this.componentResolver.resolveComponent(this.treeModel.treeNodeContentComponent)
     .then((componentFactory: ComponentFactory<{ node: TreeNode }>) => {
       let componentRef: ComponentRef<{ node: TreeNode }>
         = this.viewContainerRef.createComponent(componentFactory, 0, this.viewContainerRef.injector);
       componentRef.instance.node = this.node;
       componentRef.changeDetectorRef.detectChanges();
     });
 }
開發者ID:KilianSSL,項目名稱:angular2-tree-component,代碼行數:9,代碼來源:tree-node-content.component.ts


注:本文中的@angular/core.ComponentResolver類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。