本文整理匯總了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();
}
}