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
andnpm 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