本文整理汇总了TypeScript中@angular/core.ComponentRef.destroy方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ComponentRef.destroy方法的具体用法?TypeScript ComponentRef.destroy怎么用?TypeScript ComponentRef.destroy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/core.ComponentRef
的用法示例。
在下文中一共展示了ComponentRef.destroy方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
dialog.onDestroy.subscribe( () => {
if (typeof cmpRef.instance.canDestroy === 'function') {
cmpRef.instance.canDestroy().then ( () => cmpRef.destroy() );
} else {
cmpRef.destroy();
}
});
示例2: ngOnDestroy
/**
* On destroy
*/
ngOnDestroy(): void
{
if ( this.previewRef )
{
this.previewRef.destroy();
}
}
示例3: ifLoader
@Input() set ifLoader(loading: boolean) {
console.log('ifLoader, loading : ', loading);
if (loading) {
// create and attach a loader to our viewContainer
const factory = this.cfResolver.resolveComponentFactory(LoaderSpinnerComponent);
this.loaderComponentRef = this.viewContainer.createComponent(factory);
// remove any embedded view
if (this.embeddedViewRef) {
this.embeddedViewRef.destroy();
this.embeddedViewRef = null;
}
} else {
// remove any loader
if (this.loaderComponentRef) {
this.loaderComponentRef.destroy();
this.loaderComponentRef = null;
}
// create and attach our embeddedView
this.embeddedViewRef = this.viewContainer.createEmbeddedView(this.templateRef);
}
}
示例4: cleanup
protected cleanup():void {
super.cleanup();
if (this._contentComponentRef) {
this._contentComponentRef.destroy();
this._contentComponentRef = undefined;
}
}
示例5: removeDrawerElements
private removeDrawerElements() {
const windowNativeEl = this.drawerCmptRef.location.nativeElement;
windowNativeEl.parentNode.removeChild(windowNativeEl);
this.drawerCmptRef.destroy();
if (this.backdropCmptRef) {
const backdropNativeEl = this.backdropCmptRef.location.nativeElement;
backdropNativeEl.parentNode.removeChild(backdropNativeEl);
this.backdropCmptRef.destroy();
}
if (this.contentRef && this.contentRef.viewRef) {
this.contentRef.viewRef.destroy();
}
this.drawerCmptRef = null;
this.contentRef = null;
}
示例6:
this._resolver.resolveComponent(this.pageComponentType).then(factory => {
if (this._pageComponent) {
this._pageComponent.destroy();
}
this._pageComponent = this._viewContainer.createComponent(factory, 0, this._viewContainer.injector);
// dirty fix to insert in correct position
const pageElement = this._pageComponent.location.nativeElement
this._elementRef.nativeElement.appendChild(pageElement);
});
示例7: _removeModalElements
private _removeModalElements() {
const windowNativeEl = this._windowCmptRef.location.nativeElement;
windowNativeEl.parentNode.removeChild(windowNativeEl);
this._windowCmptRef.destroy();
if (this._backdropCmptRef) {
const backdropNativeEl = this._backdropCmptRef.location.nativeElement;
backdropNativeEl.parentNode.removeChild(backdropNativeEl);
this._backdropCmptRef.destroy();
}
if (this._contentRef && this._contentRef.viewRef) {
this._contentRef.viewRef.destroy();
}
this._windowCmptRef = null;
this._backdropCmptRef = null;
this._contentRef = null;
}
示例8:
this.setDisposeFn(() => {
(this._appRef as any).unregisterChangeDetector(changeDetectorRef);
// Normally the ViewContainer will remove the component's nodes from the DOM.
// Without a ViewContainer, we need to manually remove the nodes.
let componentRootNode = this._getComponentRootNode(componentRef);
if (componentRootNode.parentNode) {
componentRootNode.parentNode.removeChild(componentRootNode);
}
componentRef.destroy();
});
示例9: _removeModalElements
private _removeModalElements() {
const notificationNativeEl = this._notificationCmptRef.location.nativeElement;
notificationNativeEl.parentNode.removeChild(notificationNativeEl);
this._notificationCmptRef.destroy();
if (this._contentRef && this._contentRef.viewRef) {
this._contentRef.viewRef.destroy();
}
this._notificationCmptRef = null;
this._contentRef = null;
}
示例10: ngAfterViewInit
ngAfterViewInit() {
if (this.column.def.component) {
if (this.componentRef) {
this.componentRef.destroy();
}
const cmpFactory = this.resolver.resolveComponentFactory(this.column.def.component);
const ctxInjector: Injector = this.cmpContainer.injector;
this.componentRef = this.cmpContainer.createComponent(cmpFactory, 0, ctxInjector);
const instance: any = this.componentRef.instance;
instance['row'] = this.row;
instance['column'] = this.column;
instance['key'] = this.column.def.key;
instance['value'] = this.getValue();
this.componentRef.changeDetectorRef.detectChanges();
}
}