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


TypeScript core.DynamicComponentLoader類代碼示例

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


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

示例1: attachComponentPortal

  /** Attach the given ComponentPortal to this PortlHost using the DynamicComponentLoader. */
  attachComponentPortal(portal: ComponentPortal): Promise<ComponentRef<any>> {
    portal.setAttachedHost(this);

    // If the portal specifies an origin, use that as the logical location of the component
    // in the application tree. Otherwise use the location of this PortalHost.
    let viewContainerRef = portal.viewContainerRef != null ?
        portal.viewContainerRef :
        this._viewContainerRef;

    // Typecast is necessary for Dart transpilation.
    return this._dynamicComponentLoader.loadNextToLocation(portal.component, viewContainerRef)
      .then(ref => {
        this.setDisposeFn(() => ref.destroy());
        return ref;
      });
  }
開發者ID:AlexYates,項目名稱:material2,代碼行數:17,代碼來源:portal-directives.ts

示例2: constructor

  constructor(dcl: DynamicComponentLoader, viewContainerRef: ViewContainerRef) {
  	
  	this.cities = [];
    this.cities.push({label:'New York', value:'New York'});
    this.cities.push({label:'Rome', value:'Rome'});
    this.cities.push({label:'London', value:'London'});
    this.cities.push({label:'Istanbul', value:'Istanbul'});
    this.cities.push({label:'Paris', value:'Paris'});

    this.selected = 'Rome';

    dcl.loadNextToLocation(Dropdown, viewContainerRef)
    .then((res) => {
      res.instance.options = this.cities;
      res.instance.value = this.selected;
    });

  }
開發者ID:evilkyro1965,項目名稱:learn-angular2,代碼行數:18,代碼來源:boot.ts

示例3:

 _loadTreeNodeContent() {
   this.componentLoader.loadNextToLocation(this.treeModel.treeNodeContentComponent,
                                           this.viewContainerRef)
     .then((componentRef) => {
       componentRef.instance.node = this.node;
     });
 }
開發者ID:Rexota,項目名稱:angular2-tree-component,代碼行數:7,代碼來源:tree-node-content.component.ts

示例4:

	ngOnInit() {
		for(var i = 0; i < this.grid.length; i++) {
			var selector: string = '.tile-content-' + i;
			var tile = this.grid[i];
			this.loader.loadAsRoot(tile.component, selector, this.injector);	
		}
	}
開發者ID:samfcmc,項目名稱:piframe,代碼行數:7,代碼來源:dashboard.component.ts

示例5: createCmp

    createCmp(cmp, isDock = true)
    {
        window['cmpMap'] = window['cmpMap'] || {}
        window['cmpList'] = window['cmpList'] || {}
        const ref = this.dcl.loadNextToLocation(cmp, this.viewContainerRef)
        
        ref.then(ref=>
        {
                
                var name = ref['_componentType'].name
                const component = ref['_hostElement'].component
                    // console.log( 3333333,name)
                window['cmpList'][name] = window['cmpList'][name] || []
                window['cmpList'][name].push(ref)
                const id = idIndex++
                const element = $(ref['_hostElement']['nativeElement'])
                element.attr('id', id)
                window['cmpMap'][id] = ref
                
                if( !isDock )
                    return




            setTimeout(()=> 
            {
                if( name === 'UrlAppCmp' )
                    name = component.url
                
                ref.onDestroy(()=>{
                    dockMap[name].items.forEach((item, index)=>{
                        if( item._id === id )
                            dockMap[name].items.splice(index, 1)
                    })
                })    
                
                if( dockMap[name] ){
                    var data = { _id: id, title: component.title, element: element }
                    dockMap[name].items.push(data)
                    setTimeout(()=> {
                        data.title = component.title
                    }, 100);
                }
                else{
                    dockMap[name] = {_id: 'folder', items: [{ _id: id, title: component.title, element: element, component: component }], icon: component.dockbar_icon }
                    dockAppList.push(dockMap[name])
                    setTimeout(()=> {
                        dockMap[name].items[0].title = component.title
                    }, 1000);
                }
            })
            
        })
        
        return ref

        // return new 
    }
開發者ID:junjun16818,項目名稱:webos,代碼行數:59,代碼來源:commander.ts

示例6:

 this.edgeService.getCoordinates().subscribe(coordinates => {
     this.dynamicComponentLoader
         .loadNextToLocation(Edge,coordinates.first.viewContainer)
         .then((res) => {
           res.instance.setCoordinates(coordinates.first, coordinates.second);
         })
         .catch(e => console.log(e));
 });
開發者ID:ManfredGit,項目名稱:angular-2-samples,代碼行數:8,代碼來源:graph.ts

示例7: clicking

  clicking() {
    console.log('nir clicked');

    this.dcl.loadNextToLocation(FreeTextOperandTemplate, this.target)
      .then(cmpRef => {
        //cmpRef.instance.freeText.value = this.baz;
        console.log(cmpRef.instance.freeText);
      });
  }
開發者ID:nirpeer,項目名稱:ng2-ruler,代碼行數:9,代碼來源:dashboard.component.ts

示例8: ngOnInit

 ngOnInit(){
   this._loader.loadAsRoot(this.steps[0].component, '#multistep-outline', this.injector);
   this.steps.forEach((obj, iter)=> {
     if(iter === 0) {
       this.stepStyles[iter] = 'doing';
     }
     else {
        this.stepStyles[iter] = 'todo';
     }
   });
   this.lastStepNumber = this.steps.length;
 }
開發者ID:kaadash,項目名稱:ng2-multistep,代碼行數:12,代碼來源:multistep.component.ts

示例9: changeStep

 changeStep(stepNumber){
   if(stepNumber < this.lastStepNumber && stepNumber >= 0) {
     this._loader.loadAsRoot(this.steps[stepNumber].component, '#multistep-outline', this.injector);
     for (let i = stepNumber - 1; i >= 0; i--) {
       this.stepStyles[i] = 'done';
     }
     this.stepStyles[stepNumber] = 'doing';
     for (let i = stepNumber + 1; i < this.lastStepNumber; i++) {
       this.stepStyles[i] = 'todo'; 
     }
     this.currentStep = stepNumber;
   }
 }
開發者ID:kaadash,項目名稱:ng2-multistep,代碼行數:13,代碼來源:multistep.component.ts

示例10: handleRouteChange

  handleRouteChange(def: RouteDefinition) {
    this.loader.loadNextToLocation(def.component, this.containerRef)
      .then((ref:ComponentRef<any>) => {
        // Clean up any old component that may not have finished animating out.
        this.destroyPreviousComponent(this.prevComponentRef);

        this.prevComponentRef = this.currComponentRef;
        this.currComponentRef = ref;

        // Clean up the old component after letting it animate out.
        setTimeout(this.destroyPreviousComponent.bind(this, this.prevComponentRef),
            MAX_VIEW_ANIMATION_DURATION);
      });
  }
開發者ID:levilindsey,項目名稱:aldenwitt.com,代碼行數:14,代碼來源:router-outlet.component.ts


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