How to create 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)
- Which stylesheet format would you like to use? (CSS, SCSS, or Sass)
- Would you like to add a unit testing library? (Jest or None)
-
Answer the questions and press Enter to create the project.
Project structure:
The Angular CLI will create a new project with the following structure:
my-app/
app/
app.component.ts
app.component.html
app.component.css
app.module.ts
...
node_modules/
...
package.json
The app
folder contains the main application code, while node_modules
contains the dependencies installed by npm. package.json
is the project configuration file.
Start the development server:
- Navigate to the project directory:
cd my-app
- Run the following command to start the development server:
ng serve
This will start the Angular development server, which will serve your application at
http://localhost:4200
.
Open the application in a browser:
- Open a web browser and navigate to
http://localhost:4200
. - You should see the default Angular application page.
That's it! You now have a new Angular project up and running. You can start building your application by modifying the code in the app
folder.