Skip to content

Bootstrap multiple standalone components #51331

@emeryao

Description

@emeryao

Which @angular/* package(s) are relevant/related to the feature request?

core

Description

bootstrap multiple standalone components is now not supported whille it can be done with NgModule

there is index.html like below

<html>
<body>
    <some-ng-component></some-ng-component>
    <app-root></app-root>
</body>
</html>

both the app-root and some-ng-component are components declared by @Component

with NgModule both the components can be bootstrap at the same time by app.module.ts and main.ts

// app.module.ts
@NgModule({
    bootstrap: [
        AppComponent,
        SomeNgComponent,
    ],
})
export class AppModule { }

// main.ts
platformBrowserDynamic().bootstrapModule(AppModule)
    .catch(err => console.error(err));

but with standalone components it can only bootstrap one componet at a time

// main.ts
bootstrapApplication(AppComponent, appConfig)
    .catch(err => console.error(err));

Proposed solution

multiple standalone components can be bootstrapped in main.ts

may be a component array will be accepted in the bootstrapApplication function like

// main.ts proposed
bootstrapApplication([AppComponent, SomeNgComponent], appConfig)
    .catch(err => console.error(err));

Alternatives considered

the other component I want to bootstrap with AppComponent may often has some non-biz logic like titlebar or action bar or a welcome screen that should be initialized at the earliest time


Sorry for my poor English 😅

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: coreIssues related to the framework runtimecross-cutting: standaloneIssues related to the NgModule-less world

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions