0
0
Angularframework~5 mins

Running and serving an Angular app

Choose your learning style9 modes available
Introduction

Running and serving an Angular app lets you see your app in a web browser while you build it. It helps you test and check your work live.

You want to see your Angular app in a browser during development.
You need to test how your app looks and works on different devices.
You want to share your app locally with others on the same network.
You want to check if your app updates automatically when you change code.
Syntax
Angular
ng serve [options]

ng serve is the main command to run and serve your Angular app locally.

You can add options like --port to change the port or --open to open the browser automatically.

Examples
Runs the app on the default port 4200 and watches for code changes.
Angular
ng serve
Runs the app and opens it automatically in your default web browser.
Angular
ng serve --open
Runs the app on port 4300 instead of the default 4200.
Angular
ng serve --port 4300
Sample Program

This command starts the Angular development server and opens your app in the browser at http://localhost:4200. The server watches your files and reloads the app automatically when you save changes.

Angular
/* Run this command in your Angular project folder */
ng serve --open
OutputSuccess
Important Notes

Make sure you run ng serve inside your Angular project folder where angular.json is located.

If port 4200 is busy, Angular will suggest another port or you can specify one with --port.

Use Ctrl + C in the terminal to stop the server when done.

Summary

ng serve runs your Angular app locally for testing and development.

You can customize the port and open the browser automatically with options.

The server reloads your app live when you save changes to your code.