Now we are done with the Angular installation part. In this article, we are going to learn how to create a new Angular app and serve it into the browser. Let’s get started and create our first Angular app.
Create Angular Application Using Command-Line (cmd/terminal)
The commands/steps to create and execute your first app are given below.
Step 1: Open your window terminal and run the command:
ng new my-app
- my-app is the name of our app
- ng new is used to create a new app.
Step 2: Then select the stylesheet you want to use in your project.
Step 3: Now we need to move to our project directory and run the below command to serve.
cd my-app ng serve --open
- We use cd to change the current directory to our project folder.
- ng serve is used to build, rebuild if any changes are made, and serve it.
- –open is used to open the browser.
Now it will open into your default browser at (http://localhost:4200) path which is Angular-CLI’s default serving path.
Let’s print Hello World to check whether it is working or not. Let’s open it with a suitable IDE and do it.
- Go to src folder
- Then open the app folder
- And then open component.html
- Write the code in the file to print Hello World in angular.
- Save it and check the output in your browser.
Conclusion
In this tutorial, we have learned the most basic yet important topic of Angular. In upcoming articles, we will move into the various topics of Angular and how it actually works. Throughout this tutorial, you will be learning Angular from basics to advanced step by step and can make your own app at the end.