|
Setting up a local environment for Angular development is the first step to building powerful, scalable web applications. This guide will walk you through the entire process, from installing the necessary tools to creating and running your first Angular project. PrerequisitesSteps to Setup Local Environment in AngularStep 1: Install Angular CLIThe Angular Command Line Interface (CLI) is a powerful tool for initializing, developing, and maintaining Angular applications. To install Angular CLI globally on your system, run the following command in your terminal: npm install -g @angular/cli Step 2: Create a New Angular ProjectOnce the Angular CLI is installed, you can create a new Angular project. Navigate to the directory where you want to create your project, then run: ng new gfg-angular During the project setup, the CLI will prompt you to choose various configuration options, such as adding Angular routing and selecting a stylesheet format (CSS, SCSS, etc.). Choose the options that suit your project needs. Step 3: Navigate to Your Project DirectoryAfter the project is created, navigate into the project directory: cd gfg-angular Folder Structure:Folder Structure Dependencies:"dependencies": { Step 4: Serve the ApplicationTo serve your application locally and start the development server, run: ng serve By default, the Angular development server runs on http://localhost:4200/. Open your browser and navigate to this URL to see your new Angular application in action. Step 5: Edit Your First Angular ComponentThe Angular CLI generates a default application structure with a root module and a root component. Let’s edit the root component to display a custom message. Open src/app/app.component.html and replace its contents with:
Step 6: Install Additional DependenciesAs you develop your application, you may need to install additional libraries and dependencies. For example, to install Angular Material, run: ng add @angular/material Step 7: Building the Application for ProductionWhen your application is ready for deployment, you need to build it for production. Run the following command: ng build --prod This command compiles your application into an optimized bundle, stored in the dist/ directory. You can then deploy this directory to your web server. Output:Local Environment Setup in Angular |
Reffered: https://www.geeksforgeeks.org
AngularJS |
Related |
---|
![]() |
![]() |
![]() |
|
![]() |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 15 |