FrancescoDonzello
Angular Share on Twitter

Project Setup

3 minutes read
#courses#angular

Welcome to this free course for learning how to create an enteprise Angular project from scratch by using only Standalone Components.

Create a new Angular project

npx @angular/cli@^16 new train-online --style=scss --package-manager=pnpm --skip-tests --routing=false --standalone --prefix=fradev

Let me explain this command:

Version warning

--standalone is only available starting with Angular 16.

The new Project File Tree

You can clearly see that there is no app.module.ts anymore.

But, you may have noticed a new entry, app.config.ts. Here’s the content:

app.config.ts
import { ApplicationConfig } from '@angular/core';
 
export const appConfig: ApplicationConfig = {
  providers: []
};

This file specifies what to provide to your root component, similar to the app.module.ts providers array.

Another change worth to mention is in the main.ts.

main.ts
import { bootstrapApplication } from '@angular/platform-browser';
import { appConfig } from './app/app.config';
import { AppComponent } from './app/app.component';
 
bootstrapApplication(AppComponent, appConfig)
  .catch(console.error);

It’s now clear that our root component is the AppComponent and that the appConfig is being used here.

Test it out

Run the development server:

pnpm start

You’ll see the content of AppComponent in the browser.

Note that in the index.html you’ll find fradev-root wich matches the selector of the AppComponent.

The Github Repo

You can find the source code of this step of the course right on GitHub.

What’s next

In the next chapter, we’ll see how to add TailwindCSS to the project and how to give the project a simple but effective layout.

Was it helpful?

Tell your friends or co-workers.