Getting started with Angular involves a few key steps to set up your development environment and create your first Angular application.
Node.js is a Javascript runtime that allows developers to run Javascript code outside of a web browser. npm (Node Package Manager) is a package manager for Node.js that helps us to manage dependencies and libraries for our projects. We can download and install Node.js from the official website:
For Mac: Click Here For Windows: Click Here
Angular CLI (Command Line Interface) is a powerful tool for initializing, developing, scaffolding, and maintaining Angular applications.
npm install -g @angular/cli
To Install `@angular/cli` globally on our machine. we can use the below npm command for the same:
ng new my-first-angular-app
Use Angular CLI to create a new Angular project. Open your terminal or command prompt, navigate to the directory where you want to create your project and run:
cd my-first-angular-app
This will create a new Angular project named `my-first-angular-app` with the necessary files and folder structure.
ng serve
After the project is created, navigate into the project directory:
We can serve our Angular application locally using Angular CLI's development server. Run the below command to start serving Angular application locally:
This will compile the application and launch a development server. we can access an application at `http://localhost:4200` in our web browser.
Take some time to explore the project structure created by Angular CLI. Key directories include:
"src": Contains the source code of your Angular application.
"src/app": Contains the components, templates, styles, and other files for your application.
"angular.json": Configuration file for Angular CLI.
"package.json": npm package configuration file containing dependencies and scripts.
"src/assets": Can Contains the images, fonts, videos, and other files for our application.
"src/index.html": is the main HTML file for our Angular application. It serves as the entry point for our application and is where the Angular application is bootstrapped.
src/styles.css: The global styles file for our application.
Now, We can start making changes to our Angular application. Open the project in your favourite code editor and explore the code generated by Angular CLI.
Modify the components, templates, and styles as needed.