Use the Angular project template with ASP.NET Core
Create a new app
dotnet new angular -o my-new-app cd my-new-app
Add pages, images, styles, modules, etc.
The ClientApp
directory contains a standard Angular CLI app
Run ng commands
remove package-lock.json
then :
cd ClientApp npm install
Install npm packages
cd ClientApp npm install --save <package_name>
Run “ng serve” independently
cd ClientApp npm start
Use npm start
to launch the Angular CLI development server, not ng serve
, so that the configuration in package.json is respected. To pass additional parameters to the Angular CLI server, add them to the relevant scripts
line in your package.json file.
In your Startup
class, replace the spa.UseAngularCliServer
invocation with the following:
spa.UseProxyToSpaDevelopmentServer("http://localhost:4200");