标签:route err ret clear 测试 相关 imp eal factory
"component-selector": [
true,
"element",
"makealife",
"kebab-case"
]
<ng-container #stepperContainer></ng-container>
<ng-container *ngIf="!isStepperComponentLoaded">
...
</ng-container>
import { Component, ComponentFactoryResolver, OnInit, ViewChild, ViewContainerRef } from '@angular/core';
export class XXXComponent implements OnInit {
constructor(private componentFactoryResolver: ComponentFactoryResolver) { }
loadStepperComponent() {
const componentFactory = this.componentFactoryResolver.resolveComponentFactory(ConfigStepperComponent);
this.stepperContainer.clear();
this.stepperContainer.createComponent(componentFactory);
this.isStepperComponentLoaded = true;
}
}
this.router.routeReuseStrategy.shouldReuseRoute = function () {
return false;
};
this.mySubscription = this.router.events.subscribe((event) => {
if (event instanceof NavigationEnd) {
// Trick the Router into believing it's last link wasn't previously loaded
this.router.navigated = false;
}
});
ngOnDestroy() {
if (this.mySubscription) {
this.mySubscription.unsubscribe();
}
}
标签:route err ret clear 测试 相关 imp eal factory
原文地址:https://www.cnblogs.com/wyp1988/p/12510068.html