top of page

Angular set up

Install Angular & Visual Studio CODE

Next link explains the steps to follow.

https://www.youtube.com/watch?v=QZQTKx4LkgA&index=1&list=PL0kIvpOlieSMnuoW0QX8N-wWhJpCcIDvZ

Prerequisites for Angular latest version installation

Angular requires Node.js version 8.x or latest.

To get Node.js, go to https://nodejs.org/en/

To check your version,

Open the Windows Command prompt as administrator

 run node -v in a terminal/console window.

npm also automatically gets installed along with node, no need to install separately.

To check npm version,

run npm -v in a terminal/console window.

Step 1: Install the Angular CLI

To install angular cli, run the below command in command prompt with administrator mode

npm install -g @angular/cli

To check Angular CLI version,

run ng -v in a terminal/console window.

Step 2 : Create a workspace and initial application

Run the below command in the folder where you want to create your project,

< workspace_folder_path >ng new <projectname>

Example

CD C:\Angular projects

ng new projectAngular1

It will prompt you a question as Would you like to add Angular routing?, say yes

And then it asks for choosing stylesheet type, choose CSS.

Step 3: Serve the application

Go to the workspace folder (inside your project).

Launch the server by using the CLI command ng serve, with the --open option.

cd <workspace_folder_path>

cd projectAngular1

ng serve –-open

project gets compiled and it shows the default url to run the application localhost:4200

Now, go to browser and run with below url

 localhost:4200

Install visual studio code using below link

Visual studio code link for download: https://code.visualstudio.com/

File->open folder->select the project

 

To run application using visual studio code use

View->Terminal-> or ctrl+`

To compile application in terminal use below command

Ng serve

For more details

1. For Setup, https://angular.io/guide/quickstart

2. Connect to TFS reference url: https://stackoverflow.com/questions/48056972/how-to-connect-tfs-in-visual-studio-code

3. Sample application reference url: https://www.devglan.com/angular/angular-7-crud-example

4. To Enable debugging reference url: https://code.visualstudio.com/docs/introvideos/debugging

Install bootstrp

npm install --save @ng-bootstrap/ng-bootstrap

then

npm install --save @ng-bootstrap/ng-bootstrap

Fire base dependencies 

npm install firebase @angular/fire font-awesome bootstrap @ng-bootstrap/ng-bootstrap --save

ASP .NET MVC + Angular
Youtube link Angular CLI with ASP.NET MVC, in Visual Studio 2017 

1.- Create a simple angular project. " C:\Angular projects\angular"

2.-Create a simple Asp .net MVC project.  " C:\MVC-projects\angularMVC"

3.-Copy everything but "node_modules" from the angular project folder ("C:\Angular projects\angular") to the asp .net MVC project(" C:\MVC-projects\angularMVC") by right clicking on the project inside the Visual Studio Solution Explorer, and paste.

4.- Right click on the package.json file and select Restore Packages.

Scripts required

For_layout.cshtml include

<head>

 <base href="/"/>

</head>

After bundles in body include

<script type="text/javascript" src="~/dist/angularMVC/runtime.js"></script>
  <script type="text/javascript" src="~/dist/angularMVC/polyfills.js"></script>
  <script type="text/javascript" src="~/dist/angularMVC/styles.js"></script>
  <script type="text/javascript" src="~/dist/angularMVC/vendor.js"></script>
  <script type="text/javascript" src="~/dist/angularMVC/main.js"></script>

note: angularMVC is the angular folder name created, replace it as you created.

In the index.cshtml

Replace content for the <app-root></app-root>

RootConfig.cs

 public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                name: "Default",
                url: "{*url}",  //  url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
        }

NOTE: run  ng build --aot in a terminal or command prompt whenever you modify anything.

bottom of page