How to create new angular app
To create a new Angular app, you can use the Angular CLI (Command-Line Interface). Here are the steps:
Prerequisites:
- Node.js installed on your machine (version 14 or higher)
- npm (Node Package Manager) installed on your machine
- A code editor or IDE of your choice
Step 1: Install the Angular CLI
Open a terminal or command prompt and run the following command:
npm install -g @angular/cli
This will install the Angular CLI globally on your machine.
Step 2: Create a new Angular app
Run the following command to create a new Angular app:
ng new my-app
Replace my-app
with the name of your app.
Step 3: Choose the app template
The Angular CLI will prompt you to choose a template for your app. You can choose from the following options:
blank
: A blank app with no pre-built featuresrouting
: An app with routing enabledservice-worker
: An app with a service worker enabledpwa
: A Progressive Web App (PWA) with routing and service worker enabled
Choose the template that best fits your needs.
Step 4: Configure the app
The Angular CLI will ask you to configure your app. You can choose the following options:
Language
: Choose the programming language for your app (e.g., TypeScript, JavaScript)Style
: Choose the CSS preprocessor for your app (e.g., Sass, Less)Prefix
: Choose the prefix for your app's CSS classes (e.g.,app-
,my-app-
)
Choose the options that best fit your needs.
Step 5: Create the app
Once you've configured your app, the Angular CLI will create the app structure and install the necessary dependencies.
Step 6: Start the app
Run the following command to start the app:
ng serve
This will start the app in development mode, and you can access it by navigating to http://localhost:4200
in your web browser.
Step 7: Build and deploy the app
Once you've developed your app, you can build it using the following command:
ng build
This will create a production-ready build of your app. You can then deploy the app to a production environment using your preferred deployment method (e.g., hosting on a server, deploying to a cloud platform).
That's it! You've created a new Angular app using the Angular CLI.