Visual Studio 2017: Adding Angular with a simple method - TechNet Articles - United States (English) - TechNet Wiki


Table of Contents

Visual Studio 2017: Adding Angular with a simple method


Table of Contents

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.

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 on the below list.

AngularJS

Step 5

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

AngularJS

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

AngularJS

Step 6

It will take a few minutes to add AngularJS to 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 the name as “Test.htm”.

AngularJS

Step 8

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

AngularJS

Code


<!DOCTYPE html>
<html>
  
<head>
 <meta charset="utf-8" />
 <script src="Scripts/angular.js"></script>
ode> <title></title>
</head>
  
<body ng-app>
 <h2>Welcome to angularJS Test Page</h2> <br />
 <h3>Addition</h3> {{10+10}} <br />
 <h3>Subtraction</h3> {{30-10}} <br />
 <h3>Multiplication</h3> {{5*4}} <br />
 <h3>Division</h3> {{100/5}} <br /> </body>
  
</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.