Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit eed7699

Browse files
committed
minor title adjustment.
1 parent 194ff72 commit eed7699

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

public/docs/ts/latest/cookbook/angular-dotnet-core.md

+13-18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# Cookbook Introduction
2-
31
This cookbook describes how to build a .NET Core Web application with an Angular app running inside the MVC architecture.
42
.NET Core is cross platform. You can develop .NET Core application on Windows, MacOS or Linux, with tools of your own choices. This cookbook will describe how to build the application with Visual Studio 2015 on Windows. You can develop and run the project created in Visual Studio 2015 on all supported platforms with .NET Core CLI, but it is out of this cookbook’s scope, please refer to .NET Core official documentations.
53

@@ -26,7 +24,9 @@ This cookbook is focused on getting Angular app to work within .NET Core applica
2624
* Select `ASP.NET Core Web Application (.NET Core)` template, give the project a name (this cookbook uses `AngularWithDotnetCore`), and click OK.
2725
* Select `Web Application` and click OK. Wait for visual studio to restore packages.
2826

29-
# Create Configuration files for your Angular app.
27+
# Create your Angular app
28+
29+
## Create Configuration files for your Angular app.
3030

3131
In the root folder, create `package.json` and `tsconfig.json` files. Populate them by pasting the contents below.
3232

@@ -300,11 +300,11 @@ The above code asks .NET Core to redirect any request asking for resources in `/
300300

301301
Rebuid and run the application again, you will see "Hello Angular!" on top of the default MVC welcome message.
302302

303-
## Move Angular app to its own Controller and View
303+
# Move Angular app to its own Controller and View
304304

305305
Now, you have seen that the Angular app is working. However, By boostraping it inside `Views/Shared/_layout.cshtml` for a quick test, you will find that every MVC pages bootstraps your Angular app. Let's move your Angular app into its own Controller and View, so that user can click a navigation link in the navbar and go to `/app` to start the Angular app.
306306

307-
### Create Controller and View for the Angular app
307+
## Create Controller and View for the Angular app
308308

309309
1. Create a MVC Controller called `AppController`
310310

@@ -348,15 +348,15 @@ Now, you have seen that the Angular app is working. However, By boostraping it i
348348
<li><a asp-area="" asp-controller="App" asp-action="Index">Angular App</a></li>
349349
```
350350
351-
### Build and run
351+
## Build and run
352352
353353
Now click `F5` to build and run the project. Click `Angular App` in the top navigation, you will see `Hello Angular!`. Click `About` and the app will navigate to the default `About` page and click `Angular App` again, you will be navigated back to the Angular app.
354354
355355
If the Angular app has only one page, this would be the end of this cookbook. However, a typical Angular app would have many pages with many modules. It would also lazy load modules via router. In the following sections, you will replace the above basic angular app with the sample application used in `Router & Navigation` charpter and make it work inside .NET Core environment.
356356
357-
## The Sample application
357+
# The Sample application
358358
359-
### Download and copy the sample application
359+
## Download and copy the sample application
360360
361361
1. Click [here](https://angular.io/resources/live-examples/router/ts/plnkr.html) to open the live example of `Router & Navigation`. Feel free to explore the application before click the `Download your plunk as a ZIP file` at the right up corner.
362362
@@ -367,11 +367,11 @@ If the Angular app has only one page, this would be the end of this cookbook. Ho
367367
368368
Your `app` folder in the .NET Core project should contain everything in the downloaded `app` folder and `systemjs.config.js` file created previously.
369369
370-
### Add styles
370+
## Add styles
371371
372372
To style your Angular app the same way as the sample application, open `Views/Shared/_layout.cshtml` and insert `<link href="~/css/styles.css" rel="stylesheet" />` next to `<title>` tag in the `<head>` section.
373373
374-
### Set base href
374+
## Set base href
375375
376376
Base href is required by Angular Router. Because the Angular app is under .NET Core's `App` route, you will set the base href to `/app/`. Open `Views/Shared/_layout.cshtml` and insert `<base href="/app/"/>` inside the `<head>` section as the first child.
377377
@@ -381,7 +381,7 @@ To fix the above error, open `/app/Systemjs.config.js` file, find ` main: './app
381381
382382
Now, if you build and run the project and navigate to the Angular app, you will see that the app is bootstraped but it is stopped due to errors. In the `Console` tab of the browser's `Developer tools`, Angular is complaining that it `Cannot match any routes. URL Segment: 'App'`.
383383
384-
### .NET Core's Pascal Case url
384+
## .NET Core's Pascal Case url
385385
386386
.NET Core parse urls to Pascale case by default. As you have seen, it does not work well with JavaScript frameworks like Angular.
387387
@@ -396,7 +396,7 @@ Remember to insert `using Microsoft.AspNetCore.Routing;` to `startup.cs` file.
396396
397397
Now rebuild and run your application, the above error goes away. However only `Heros` and `Admin` link work. The lazy load module `Crisis Center` is broken. In the Console, the browser reports: `GET http://localhost:55771/crisis-center/crisis-center.module 404 (Not Found)`. Notice the absence of `/app/` in the path.
398398
399-
### Fix Lazy-Loading Modules
399+
## Fix Lazy-Loading Modules
400400
401401
The problem is that Angular could not find the lazy-loading modules. Let's check out `app-routing.module.ts` file in `app` folder, you can see the following:
402402
```
@@ -441,7 +441,7 @@ To fix the issue, simple use relative path like this:
441441
442442
Now, build and run, you will see that the Angular app is runing without errors until you refresh the browser.
443443
444-
## Configure .NET Core routes for Angular app
444+
# Configure .NET Core routes for Angular app
445445
446446
The Angular app has deep links, such as `/app/heros` and `/app/heros/11`. When you navigate inside the Angular app, it does not send any request to the .NET Core server. However, when you refresh the browser with deep links, the browser send request to .NET Core server and expect .NET Core to response.
447447
@@ -489,8 +489,3 @@ Angular application can live inside of a larger .NET Core web application. This
489489
1. Angular router uses `base href` but .NET Core ignores it. Angular app has to use relative path for its lazy-loading modules.
490490
491491
1. Angular app's deep links does not play well with .NET Core server side routing. You can configure .NET Core routing to redirect all urls starting with `/app` to the same MVC Controller and Action.
492-
493-
494-
495-
496-

0 commit comments

Comments
 (0)