Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular CLI in ASP.NET Core 2 Angular template?

I know the basics of Angular and ASP.NET Core 2, but not on the level that would allow me to understand how this template works.

I tried generating components using Angular CLI in Visual Studio Code, however, it says I don't have the CLI. I think it's the webpack thingy that keeps the CLI and allows all the cool stuff that comes with the template, but is there a way to use the CLI despite that? Or do I have, for example, generate components manually by creating the files and adding dependecies?

I can't find any documentation on the template or a tutorial that would use it.

like image 492
Nech Avatar asked Oct 19 '17 09:10

Nech


People also ask

Can we use angular with ASP NET core?

The updated Angular project template provides a convenient starting point for ASP.NET Core apps using Angular and the Angular CLI to implement a rich, client-side user interface (UI). The template is equivalent to creating an ASP.NET Core project to act as an API backend and an Angular CLI project to act as a UI.

How do I run angular and .NET core project?

To start the project, press F5 or select the Start button at the top of the window. You will see two command prompts appear: The ASP.NET Core API project running. The Angular CLI running the ng start command.


1 Answers

First of all after installing angular cli globally:

npm install @angular/cli@latest -g

You have to first create an angular project outside your main project with this command:

ng new hello-world

Now, go to project directory and copy .angular-cli.json file into the root of your main dot net core project. Then you have to edit this part of the file:

"root" : "src" change to "root" : "ClientApp"

Next, you have to install angularCli dev in your root of your project:

cd DotNetCoreProject

npm install @angular/cli@latest --save-dev

Everythings was done!

Now, go to your component directory of your project:

cd ClientApp/app/components

and make your component in component directory in terminal:

ng g c MyComponent --module='app.module.browser.ts'

like image 86
Ashkan Rahmani Avatar answered Sep 28 '22 18:09

Ashkan Rahmani