本文整理汇总了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;未经允许,请勿转载。 |
请发表评论