Thursday, 13 May 2021

ASP.NET Core 5 and Angular

 


Installing the Angular CLI

npm install -g @angular/cli@11.0.1

 or the latest.

npm install -g @angular/cli@latest

Creating a new Angular app

ng new ClientHREmp

Wait for the tool to complete the task, and then do the following:

  • Type cd ClientHREmp to enter the newly created folder
  • Execute the npm install and npm update commands to update the npm packages

Switch client app by updating the Startup.cs file

configuration.RootPath = "ClientApp/dist";
--> configuration.RootPath = "ClientHREmp/dist";
spa.Options.SourcePath = "ClientApp"; --> spa.Options.SourcePath = "ClientHREmp";

----------------------------------------------------
dotnet new angular -o HREmp

CREATING COMPONENTS USING THE ANGULAR CLI

ng generate component health-check --skipTests=true

OR ng g c employee --module app --skipTests=true

--------------------------------------
Create the sample API to return a "Hello world" by get route 

    [Route("api/[controller]")]
    [ApiController]
    public class ApiController : ControllerBase
    {
        [HttpGet]
        public IActionResult SayHello(string name)
        {
            return this.Ok(string.Format("hello, {0}!",name));
        }
    }

No comments:

Post a Comment

Implemented a Service to receive real time message from an API Webhook

 What is the webhook?  Ask Google :) 😅  This is my experience to build a Azure Function HTTP trigger to receive an event from SkyBox API W...