How to create a new angular project
To create a new Angular project, you can use the Angular CLI (Command-Line Interface). Here are the steps:
Prerequisites:
- Node.js installed on your system (version 14 or higher)
- npm (Node Package Manager) installed on your system
- Angular CLI installed globally on your system (run
npm install -g @angular/cli
if you haven't already)
Create a new Angular project:
-
Open a terminal or command prompt.
-
Run the following command to create a new Angular project:
ng new my-app
Replace
my-app
with the name of your project. -
The Angular CLI will ask you a few questions:
- Would you like to add Angular routing? (y/n) - press Enter to accept the default (y)
- Which stylesheet format would you like to use? (CSS, SCSS, Sass, Less) - choose one (e.g., CSS)
-
The Angular CLI will create a new directory with the name you specified, and initialize a new Angular project.
Explore your new project:
-
Navigate to the project directory:
cd my-app
-
Run
ng serve
to start the development server:ng serve
This will start the development server and open your project in your default web browser.
-
You can now explore your project structure and files:
src/
directory contains the source code for your applicationapp/
directory contains the main application component and other componentsstyles.css
is the main stylesheet for your applicationmain.ts
is the entry point for your application
Next steps:
- Start building your application by creating new components, services, and other features.
- Run
ng serve
to see your changes in action. - Use the Angular CLI to generate new components, services, and other features using the
ng generate
command.
That's it! You now have a brand new Angular project up and running.