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

Commit ce0af2a

Browse files
committed
move code to _example
1 parent eed7699 commit ce0af2a

File tree

11 files changed

+506
-491
lines changed

11 files changed

+506
-491
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<!-- #docregion -->
2+
<!DOCTYPE html>
3+
<html>
4+
<head>
5+
<meta charset="utf-8" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>@ViewData["Title"] - AngularWithDotnetCore</title>
8+
<environment names="Development">
9+
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
10+
<link rel="stylesheet" href="~/css/site.css" />
11+
</environment>
12+
<environment names="Staging,Production">
13+
<link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.6/css/bootstrap.min.css"
14+
asp-fallback-href="~/lib/bootstrap/dist/css/bootstrap.min.css"
15+
asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute" />
16+
<link rel="stylesheet" href="~/css/site.min.css" asp-append-version="true" />
17+
</environment>
18+
@Html.ApplicationInsightsJavaScript(TelemetryConfiguration)
19+
20+
<!-- 1. Load libraries -->
21+
<!-- Polyfill for older browsers -->
22+
<script src="~/node_modules/core-js/client/shim.min.js"></script>
23+
<script src="~/node_modules/zone.js/dist/zone.js"></script>
24+
<script src="~/node_modules/reflect-metadata/Reflect.js"></script>
25+
<script src="~/node_modules/systemjs/dist/system.src.js"></script>
26+
<!-- 2. Configure SystemJS -->
27+
<script src="~/app/systemjs.config.js"></script>
28+
<script>
29+
System.import('app').catch(function(err){ console.error(err); });
30+
</script>
31+
</head>
32+
<body>
33+
34+
<div class="navbar navbar-inverse navbar-fixed-top">
35+
<div class="container">
36+
<div class="navbar-header">
37+
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
38+
<span class="sr-only">Toggle navigation</span>
39+
<span class="icon-bar"></span>
40+
<span class="icon-bar"></span>
41+
<span class="icon-bar"></span>
42+
</button>
43+
<a asp-area="" asp-controller="Home" asp-action="Index" class="navbar-brand">AngularWithDotnetCore</a>
44+
</div>
45+
<div class="navbar-collapse collapse">
46+
<ul class="nav navbar-nav">
47+
<li><a asp-area="" asp-controller="Home" asp-action="Index">Home</a></li>
48+
<li><a asp-area="" asp-controller="Home" asp-action="About">About</a></li>
49+
<li><a asp-area="" asp-controller="Home" asp-action="Contact">Contact</a></li>
50+
</ul>
51+
</div>
52+
</div>
53+
</div>
54+
<div class="container body-content">
55+
<my-app>Loading…</my-app>
56+
@RenderBody()
57+
<hr />
58+
<footer>
59+
<p>&copy; 2016 - AngularWithDotnetCore</p>
60+
</footer>
61+
</div>
62+
63+
<environment names="Development">
64+
<script src="~/lib/jquery/dist/jquery.js"></script>
65+
<script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>
66+
<script src="~/js/site.js" asp-append-version="true"></script>
67+
</environment>
68+
<environment names="Staging,Production">
69+
<script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-2.2.0.min.js"
70+
asp-fallback-src="~/lib/jquery/dist/jquery.min.js"
71+
asp-fallback-test="window.jQuery">
72+
</script>
73+
<script src="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.6/bootstrap.min.js"
74+
asp-fallback-src="~/lib/bootstrap/dist/js/bootstrap.min.js"
75+
asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal">
76+
</script>
77+
<script src="~/js/site.min.js" asp-append-version="true"></script>
78+
</environment>
79+
80+
@RenderSection("scripts", required: false)
81+
</body>
82+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import { NgModule } from '@angular/core';
2+
import { RouterModule, Routes } from '@angular/router';
3+
4+
import { CanDeactivateGuard } from './can-deactivate-guard.service';
5+
import { AuthGuard } from './auth-guard.service';
6+
import { PreloadSelectedModules } from './selective-preload-strategy';
7+
8+
// #docregion absolute
9+
const appRoutes: Routes = [
10+
{
11+
path: 'admin',
12+
loadChildren: 'app/admin/admin.module#AdminModule',
13+
canLoad: [AuthGuard]
14+
},
15+
{
16+
path: '',
17+
redirectTo: '/heroes',
18+
pathMatch: 'full'
19+
},
20+
{
21+
path: 'crisis-center',
22+
loadChildren: 'app/crisis-center/crisis-center.module#CrisisCenterModule',
23+
data: {
24+
preload: true
25+
}
26+
}
27+
];
28+
// #enddocregion absolute
29+
30+
// #docregion relative
31+
const appRoutes: Routes = [
32+
{
33+
path: 'admin',
34+
loadChildren: './admin/admin.module#AdminModule',
35+
canLoad: [AuthGuard]
36+
},
37+
{
38+
path: '',
39+
redirectTo: '/heroes',
40+
pathMatch: 'full'
41+
},
42+
{
43+
path: 'crisis-center',
44+
loadChildren: './crisis-center/crisis-center.module#CrisisCenterModule',
45+
data: {
46+
preload: true
47+
}
48+
}
49+
];
50+
// #enddocregion relative
51+
52+
@NgModule({
53+
imports: [
54+
RouterModule.forRoot(
55+
appRoutes,
56+
{ preloadingStrategy: PreloadSelectedModules }
57+
)
58+
],
59+
exports: [
60+
RouterModule
61+
],
62+
providers: [
63+
CanDeactivateGuard,
64+
PreloadSelectedModules
65+
]
66+
})
67+
export class AppRoutingModule {}
68+
69+
70+
/*
71+
Copyright 2016 Google Inc. All Rights Reserved.
72+
Use of this source code is governed by an MIT-style license that
73+
can be found in the LICENSE file at http://angular.io/license
74+
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// #docregion
2+
import { Component } from '@angular/core';
3+
@Component({
4+
selector: 'my-app',
5+
template: '<h1>Hello Angular!</h1>'
6+
})
7+
export class AppComponent { }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// #docregion
2+
import { NgModule } from '@angular/core';
3+
import { BrowserModule } from '@angular/platform-browser';
4+
import { AppComponent } from './app.component';
5+
@NgModule({
6+
imports: [ BrowserModule ],
7+
declarations: [ AppComponent ],
8+
bootstrap: [ AppComponent ]
9+
})
10+
export class AppModule { }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// #docregion
2+
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3+
import { AppModule } from './app.module';
4+
const platform = platformBrowserDynamic();
5+
platform.bootstrapModule(AppModule);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<!-- #docregion -->
2+
<script src="~/app/systemjs.config.js"></script>
3+
<script>
4+
System.import('app').catch(function(err){ console.error(err); });
5+
</script>
6+
<div style="min-height:300px">
7+
<my-app>Loading…</my-app>
8+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<!-- #docregion -->
2+
<li><a asp-area="" asp-controller="App" asp-action="Index">Angular App</a></li>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// #docregion redirect
2+
app.UseStaticFiles(new StaticFileOptions
3+
{
4+
RequestPath = new PathString("/app"),
5+
FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "app"))
6+
});
7+
app.UseStaticFiles(new StaticFileOptions
8+
{
9+
RequestPath = new PathString("/node_modules"),
10+
FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "node_modules"))
11+
});
12+
// #enddocregion redirect
13+
14+
// #docregion redirect-using
15+
using Microsoft.Extensions.FileProviders;
16+
using System.IO;
17+
18+
// #enddocregion redirect-using
19+
20+
// #docregion lowercaseurls
21+
services.Configure<RouteOptions>(options => options.LowercaseUrls = true);
22+
// #enddocregion lowercaseurls
23+
24+
// #docregion lowercaseurls-using
25+
using Microsoft.AspNetCore.Routing
26+
// #enddocregion lowercaseurls-using
27+
28+
// #docregion route-default
29+
app.UseMvc(routes =>
30+
{
31+
routes.MapRoute(
32+
name: "default",
33+
template: "{controller=Home}/{action=Index}/{id?}");
34+
});
35+
// #enddocregion route-default
36+
37+
// #docregion route-new
38+
app.UseMvc(routes =>
39+
{
40+
routes.MapRoute(
41+
name: "default",
42+
template: "{controller=Home}/{action=Index}/{id?}");
43+
routes.MapRoute(
44+
name: "angular",
45+
template: "app/{*routes}",
46+
defaults: new { controller = "App", action = "Index" }
47+
);
48+
});
49+
// #enddocregion route-new
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<!-- #docregion -->
2+
<link href="~/css/styles.css" rel="stylesheet" />

0 commit comments

Comments
 (0)