Search code examples
angularcomponents

how to initiate angular project with standalone component


now that angular has released standalone components, can I initiate angular with only standalone component and remove NgModule all-together?


Solution

  • yes you can using the new introduced bootstrapApplication which is imported from @angular/platform-browser in the main.ts file

    here is the full code

    import { enableProdMode } from '@angular/core';
    import { bootstrapApplication } from '@angular/platform-browser';
    import { AppComponent } from './app/app.component';
    import { environment } from './environments/environment';
    if (environment.production) {
      enableProdMode();
    }
    bootstrapApplication(AppComponent)
      .catch(err => console.error(err));