本文整理汇总了TypeScript中@angular/core.ViewContainerRef.insert方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ViewContainerRef.insert方法的具体用法?TypeScript ViewContainerRef.insert怎么用?TypeScript ViewContainerRef.insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/core.ViewContainerRef
的用法示例。
在下文中一共展示了ViewContainerRef.insert方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: addComponent
addComponent() {
const factory = this.componentFactoryResolver.resolveComponentFactory(AppChart);
const ref = this.viewContainerRef.createComponent(factory);
ref.changeDetectorRef.detectChanges();
// We insert the component into the dom container
this.dynamicComponentContainer.insert(ref.hostView);
this.numElements = this.dynamicComponentContainer.length;
this.currentComponent = ref.instance;
this.container.push(ref.instance);
}
示例2: createComponent
public createComponent(data: any): void {
const injector = ReflectiveInjector.resolveAndCreate([]);
const factory = this.resolver.resolveComponentFactory(data.component);
const component = factory.create(injector);
this.dynamicComponentContainer.insert(component.hostView);
if (this.currentComponent) {
this.currentComponent.destroy();
}
this.currentComponent = component;
}
示例3: ngOnInit
ngOnInit() {
//ValueProvider { provide: any; useValue: any;}
// let providers = [{ provide: "item", useValue: this.item }, { provide: "column", useValue: this.column }];
// let inputs = ReflectiveInjector.resolve(providers);
let injector = ReflectiveInjector.fromResolvedProviders([], this.vcRef.parentInjector);
let component;
if (this.column.cell) {
let factory = this.resolver.resolveComponentFactory(this.column.cell);
component = factory.create(injector);
} else {
let factory = this.resolver.resolveComponentFactory(DefaultCellComponent);
component = factory.create(injector);
}
component.instance.column = this.column;
component.instance.item = this.item;
this.vcRef.insert(component.hostView);
}
示例4:
return promise.then((entity) => {
const component = componentFactory.create(viewContainerRef.parentInjector);
const instance = component.instance;
instance.client = client;
if (entity) {
(
instance as INgorEntityDetailComponent<Query, Params, EntityCreateDto, EntityUpdateDto, EntityDto>
).entity = this._entity = entity;
}
if (step) {
(
instance as INgorStepComponent<Query, Params, EntityCreateDto, EntityUpdateDto, EntityDto>
).step = this._step = step;
}
instance.resource = resource;
viewContainerRef.clear();
return viewContainerRef.insert(component.hostView);
});
示例5: Error
this.route.url.subscribe(urls => {
const p = [];
urls.forEach(url => {
p.push(url.path);
});
const path = p.join('/');
this.screen = this.reg.screens[this.route.routeConfig.path];
if (!this.screen) {
throw new Error('Screen not found in registry');
}
const factory = this.resolver.resolveComponentFactory<any>(this.screen.component);
const componentRef = this.container.createComponent(factory);
this.title.setTitle(this.screen.title);
componentRef.instance.viewConfig = this.screen;
Object.keys(this.route.snapshot.params).forEach(k => {
componentRef.instance[k] = this.route.snapshot.params[k];
});
this.dynamicComponentContainer.insert(componentRef.hostView);
});
示例6:
changes.forEachAddedItem((record: IterableChangeRecord<T>) => {
const view = this.viewContainerRef.createEmbeddedView(this.templateRef);
this.viewContainerRef.insert(view);
view.context.$implicit = record.item;
});
示例7:
// Inserts the component into the specified view container.
public attachToView<T>(componentRef:ComponentRef<T>, viewContainer:ViewContainerRef):void {
viewContainer.insert(componentRef.hostView, 0);
}
示例8:
).subscribeTracked(this, () => {
this.componentView.insert(this.component.hostView);
});