Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don`t mount two identical parcel component for one page with Angular 9-12. #381

Open
TarasovMV opened this issue Aug 3, 2021 · 0 comments

Comments

@TarasovMV
Copy link

I try mount 2 same micro apps in root app (Angular 12), but when I mount at second time, I get empty micro app tag. I found same issue (single-spa/single-spa#615), but it`s not work for me.

Code example.

public mount(appName: string, domElement: HTMLElement): Observable<unknown> {
        return from(System.import<ParcelConfig>(appName)).pipe(
            tap((app: ParcelConfig) => {
                mountRootParcel(app, { domElement });
            })
        );
    }
<main>
  <section class="child-app">
    <app-spa-host-widget [appName]="'child1'"></app-spa-host-widget>
    <app-spa-host-widget [appName]="'child1'"></app-spa-host-widget>
  </section>
@Component({
    selector: 'app-spa-host-widget',
    template: '<div #appContainer></div>',
    changeDetection: ChangeDetectionStrategy.Default
})
export class SpaHostWidgetComponent implements OnInit, OnDestroy {

    @Input() appName: string;
    @ViewChild('appContainer', {static: true})  appContainerRef: ElementRef;

    constructor(private singleSpaService: SingleSpaService) {}

    public ngOnInit(): void {
        this.mount().subscribe();
    }

    public ngOnDestroy(): void {
        this.unmount().subscribe();
    }

    private mount(): Observable<unknown> {
        return this.singleSpaService.mount(this.appName, this.appContainerRef.nativeElement);
    }

    private unmount(): Observable<unknown> {
        return this.singleSpaService.unmount(this.appName);
    }
}

image

What am I doing wrong?

@joeldenning joeldenning transferred this issue from single-spa/single-spa Aug 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant