Open joeskeen opened 3 weeks ago
@joeskeen
@Component({
selector: 'ns-root',
template: <GridLayout><Label text="Hello from Root Component"></Label><ns-app></ns-app></GridLayout>
,
standalone: true,
imports: [CommonModule, AppComponent]
})
export class RootComponent {}
can you try importing the App Component into the Root Component
@akhil02hero but if you make the RootComponent
standalone, you get the error I referenced earlier:
RootComponent class is a standalone component, which can not be used in the @NgModule.bootstrap array. Use the bootstrapApplication function for bootstrap instead.
The whole reason I made a RootComponent
to hold the AppComponent
was so RootComponent
could be non-standalone (and thus work).
Is your feature request related to a problem? Please describe.
According to the Issues list, it should theoretically be possible to create a NativeScript Angular application that contains standalone components; however, I have yet to figure out how to do that without crashing the application. If you look at the application that is generated using `ng new` today, everything is standalone, from the `main.ts` down. It seems that currently `@nativescript/angular` only supports bootstrapping a module, as opposed to an application/component. If I want my main app component to be a standalone component, I can import it into the `AppModule`: ```ts @NgModule({ imports: [NativeScriptModule, AppRoutingModule, AppComponent], bootstrap: [AppComponent], ``` but then it creates the compile error `AppComponent class is a standalone component, which can not be used in the @NgModule.bootstrap array. Use the bootstrapApplication function for bootstrap instead.` When I remove the `bootstrap` option: ``` The module AppModule was bootstrapped, but it does not declare '@NgModule.bootstrap' components nor a "ngDoBootstrap" method. Please define one of these. ``` This happens even if I provide an `ngDoBootstrap()` function: ```ts export class AppModule { ngDoBootstrap() { console.log('ngDoBootstrap'); } } ``` OK, so Angular wants an App Module when bootstrapped to have a non-standalone component to bootstrap. Let's try that: ```ts @Component({ selector: 'ns-root', template: `