Creating a new angular 4 project
Here's a step-by-step guide to creating a new Angular 4 project:
Prerequisites:
- Node.js installed on your system (version 8 or higher)
- npm (Node Package Manager) installed on your system
- Angular CLI (Command-Line Interface) installed on your system (you can install it by running
npm install -g @angular/cli
)
Create a new Angular 4 project:
-
Open a terminal or command prompt and navigate to the directory where you want to create your new project.
-
Run the following command to create a new Angular 4 project:
ng new my-app
Replace
my-app
with the name of your project. -
The Angular CLI will ask you a few questions to configure your project. You can choose the following options:
- Choose the project name and directory
- Choose the project template (e.g., "Blank", "PWA", "Routing", etc.)
- Choose the CSS preprocessor (e.g., "Sass", "Less", etc.)
- Choose the unit testing framework (e.g., "Jest", "Karma", etc.)
-
Once you've answered the questions, the Angular CLI will create a new directory with the name you specified, and initialize a new Angular 4 project.
Explore your new project:
-
Navigate to the project directory:
cd my-app
-
Run the following command 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 by looking at the files and directories in the project directory. You'll see the following folders:
app
: This is the main application folder, where you'll write your Angular components, services, and other code.src
: This is the source code folder, where you'll find the TypeScript files, CSS files, and other assets.node_modules
: This is the folder where npm installs the project dependencies.
-
You can also run the following command to see the project structure:
tree
This will display the project structure in a tree-like format.
That's it! You now have a new Angular 4 project up and running. You can start building your application by writing code in the app
folder and running the development server with ng serve
.