How to setup angular js 2

You need to set up your development environment before you can do anything.

Install Node.jsĀ® and npm if they are not already on your machine.

Verify that you are running at least Node.js version 8.x or greater and npm version 5.x or greater by running node -v and npm -v in a terminal/console window. Older versions produce errors, but newer versions are fine.

Then install the Angular CLI globally.

npm install -g @angular/cli

Step 2. Create a new project

Open a terminal window.

Generate a new project and default app by running the following command:

ng new my-app

The Angular CLI installs the necessary npm packages, creates the project files, and populates the project with a simple default app. This can take some time.

You can add pre-packaged functionality to a new project by using the ng add command. The ng add command transforms a project by applying the schematics in the specified package. For more information, see the Angular CLI documentation.

Angular Material provides schematics for typical app layouts. See the Angular Material documentation for details.
Step 3: Serve the application

Go to the project directory and launch the server.

cd my-app
ng serve –open

The ng serve command launches the server, watches your files, and rebuilds the app as you make changes to those files.

Using the –open (or just -o) option will automatically open your browser on http://localhost:4200/.


Leave a Reply

Your email address will not be published. Required fields are marked *