Just copy these files in your web application root folder and update your index.html.
Main purpose is to quickly set up Angular in a web application created in Visual Studio. Following steps will let you have an Angular app running with angular-cli
support in dotnetcore web application in no time.
- NodeJS and npm.
- Following example is in accordance with dotnetcore web application created in Visual Studio.
Clone this repository to a folder with project name e-g my-angular-quickstart
git clone https://github.com/AhsanRazaUK/angular-quickstart my-angular-quickstart
cd my-angular-quickstart
- Copy all files/folders (except
index.html
) frommy-angular-quickstart
folder to yourwwwroot
folder of the web application - Right-Click
package.json
file andRestore Packages
- Click
Show All Files
from top of Solution Explorer to verify eithernode_modules
folder has been created - Open
index.html
file in notepad, copy script tags and past in the head section of_Layout.cshtml
. And Saveenvironment
tag in head must look like this now
<environment include="Development">
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
<link rel="stylesheet" href="~/css/site.css" />
<!-- Polyfill(s) for older browsers -->
<script src="~/node_modules/core-js/client/shim.min.js"></script>
<script src="~/node_modules/zone.js/dist/zone.js"></script>
<script src="~/node_modules/systemjs/dist/system.src.js"></script>
<script src="~/systemjs.config.js"></script>
<script>
System.import('app/main.js').catch(function (err) { console.error(err); });
</script>
</environment>
- From body
index.html
file copy Angular component tag and replace html ofIndex.cshtml
file with that. And Save
<div class="row">
<div class="container">
<!-- Angular Component -->
<my-app>Loading AppComponent content here ...</my-app>
</div>
</div>
- Run the application (
F5
) and you must see Angular component loaded. PressF12
and clickconsole
, you may see this message.
Angular is running in the development mode. Call enableProdMode() to enable the production mode.
- Ahsan Raza
This project is licensed under the MIT License - see the LICENSE.md file for details