Friday, February 17, 2017

Angular 2 Final Part 2 : Setting up Angular 2 with Asp .Net Core

There are an number of ways to start an Angular project.
A few of  them are GitHub copy, AngularCli, yo.
Setting up Angular with Asp .Net Core is easy with yo aspnetcore-spa. yeoman or yo is a code generator.

For working with yo first node and npm (Node  Package Manager have to be installed.

Once npm is installed yo can be installed  with the command  
npm install -g yo. 
-g is used to install it globally.

Since yo is ready now generator for Asp .Net Core can be installed with the command
npm install -g generator-aspnet.

Now  it's possible to create different type of Asp .Net project like  Empty Web Application, Web Appllication Basic, Web Application (with Identity), etc.

Generator for Asp .Net Core Single Page Application can be installed by typing
npm install -g yo generator-aspnetcore-spa.

A new Angular project can be created with the comman
yo aspnetcore-spa.

This generator can be used to create not only Angular project but also Knockout, React, etc.

I am going with Angular 2. It will be prompting the Visual Studio Version, Whether you want Unit Testing the Project, the Project name, etc.

I am sticking on with Visual Studio 2015, with no Unit Testing.

Once the project is created you can open it in any editor or IDE. My preferred editor is Visual Studio Code.
By typing code . the project can be opened in Visual Studio Code.

Visual Studio Code terminal can be invoked with Ctrl+~.

Since this  is a  Asp .Net Core project it can be run with the command dotnet run.

The output can be seen by opening a browser and type http://localhost:5000 as mentioned in the output.

No comments:

Post a Comment