Way Of Adding Angular In Visual Studio 2017 With a Simple Method

Introduction

This article explains how to add Angular in Visual Studio. We can add AngularJS in many different ways to develop an application in Visual Studio.

Steps for Adding AngularJS

Step 1

Open Visual Studio 2017.

Go to File >> New >> Project. The "New Project" window will open now.
Select ASP.NET Web application (.NET Framework) under the web, give Project name, and click OK.

AngularJS

Select "Empty Project" in New ASP.NET Web Application window and click OK button.

AngularJS

Step 2

Open your empty project now. Go to Solution Explorer. You can see all the files of your project here.

AngularJS

We need to add AngularJS script and supporting files to develop an application in AngularJS. Now, we see no supporting files or script files in our project's Solution Explorer.

Step 3

We are going to add AngularJS script and supporting files. Go to Tools menu, select NuGet Package Manager, and select "Manage NuGet Packages for solutions'.

AngularJS

Step 4

NuGet-Solution window will open. Go to Browser and type “angularjs” in search text box. You will see all the related AngularJS in the below list.

AngularJS

Step 5

Select AngularJS like in below screenshot and select checkbox in the right side. We need to add AngularJS in our project. Finally, click the "Install" button.

AngularJS

Now, click OK button in preview window that looks like below screenshot.

AngularJS

Step 6

It will take a few minutes to add AngularJS in our project. After adding AngularJS, we can see this looks like the below message.

AngularJS

Before adding AngularJS, we do not have script folder in our Solution Explorer but now, we can see the script folder. We can see all scripts and support files inside the script folder.

AngularJS
AngularJS

Step 7

We are going to add a simple page and implement a simple AngularJS page, which we have added. Add simple HTML page and give name as “Test.htm”.

AngularJS

Step 8

Inherit Angular script and add the following coding in test.html page.

AngularJS

Code

  1. <!DOCTYPE html>  
  2. <html>  
  3.   
  4. <head>  
  5.     <meta charset="utf-8" />  
  6.     <script src="Scripts/angular.js"></script>  
  7.     <title></title>  
  8. </head>  
  9.   
  10. <body ng-app>  
  11.     <h2>Welcome to angularJS Test Page</h2> <br />  
  12.     <h3>Addition</h3> {{10+10}} <br />  
  13.     <h3>Subtraction</h3> {{30-10}} <br />  
  14.     <h3>Multiplication</h3> {{5*4}} <br />  
  15.     <h3>Division</h3> {{100/5}} <br /> </body>  
  16.   
  17. </html>  

Step 9

Build and run the application. We can see the exact output so our AngularJS application is working correctly. We developed simple AngularJS page using which we have added script.

AngularJS

Conclusion

This article explained how to add AngularJS in Visual Studio 2017 in a simple way. I hope this article was very useful to those who are new to learning AngularJS.


Similar Articles