Skip to content

Commit 6b60cda

Browse files
Example of adding angular2-materialize in response for aspnet#394
1 parent e0c18ab commit 6b60cda

File tree

7 files changed

+34
-3
lines changed

7 files changed

+34
-3
lines changed

templates/Angular2Spa/ClientApp/app/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ import { NavMenuComponent } from './components/navmenu/navmenu.component';
66
import { HomeComponent } from './components/home/home.component';
77
import { FetchDataComponent } from './components/fetchdata/fetchdata.component';
88
import { CounterComponent } from './components/counter/counter.component';
9+
import { MaterializeDirective } from 'angular2-materialize';
910

1011
@NgModule({
1112
bootstrap: [ AppComponent ],
1213
declarations: [
14+
MaterializeDirective,
1315
AppComponent,
1416
NavMenuComponent,
1517
CounterComponent,

templates/Angular2Spa/ClientApp/app/components/home/home.component.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11
<h1>Hello, world!</h1>
2+
3+
<ul materialize="collapsible" class="collapsible" data-collapsible="accordion">
4+
<li>
5+
<div class="collapsible-header"><i class="material-icons">filter_drama</i>First</div>
6+
<div class="collapsible-body"><p>Lorem ipsum dolor sit amet.</p></div>
7+
</li>
8+
<li>
9+
<div class="collapsible-header"><i class="material-icons">place</i>Second</div>
10+
<div class="collapsible-body"><p>Lorem ipsum dolor sit amet.</p></div>
11+
</li>
12+
<li>
13+
<div class="collapsible-header"><i class="material-icons">whatshot</i>Third</div>
14+
<div class="collapsible-body"><p>Lorem ipsum dolor sit amet.</p></div>
15+
</li>
16+
</ul>
17+
218
<p>Welcome to your new single-page application, built with:</p>
319
<ul>
420
<li><a href='https://get.asp.net/'>ASP.NET Core</a> and <a href='https://msdn.microsoft.com/en-us/library/67ef8sbd.aspx'>C#</a> for cross-platform server-side code</li>

templates/Angular2Spa/ClientApp/boot-client.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import 'angular2-universal-polyfills/browser';
2+
import 'materialize-css';
3+
import 'angular2-materialize';
24
import { enableProdMode } from '@angular/core';
35
import { platformUniversalDynamic } from 'angular2-universal';
46
import { AppModule } from './app/app.module';

templates/Angular2Spa/Views/Home/Index.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
ViewData["Title"] = "Home Page";
33
}
44

5-
<app asp-prerender-module="ClientApp/dist/main-server">Loading...</app>
5+
<app>Loading...</app>
66

77
<script src="~/dist/vendor.js" asp-append-version="true"></script>
88
@section scripts {

templates/Angular2Spa/Views/Shared/_Layout.cshtml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
<title>@ViewData["Title"] - WebApplicationBasic</title>
77
<base href="/" />
88
<link rel="stylesheet" href="~/dist/vendor.css" asp-append-version="true" />
9+
<link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
10+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.7/css/materialize.min.css">
911
</head>
1012
<body>
1113
@RenderBody()

templates/Angular2Spa/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"@angular/platform-server": "2.0.2",
1313
"@angular/router": "3.0.2",
1414
"@types/node": "^6.0.42",
15+
"angular2-materialize": "^5.2.1",
1516
"angular2-platform-node": "~2.0.11",
1617
"angular2-universal": "~2.0.11",
1718
"angular2-universal-polyfills": "~2.0.11",
@@ -27,6 +28,7 @@
2728
"file-loader": "^0.9.0",
2829
"isomorphic-fetch": "^2.2.1",
2930
"jquery": "^2.2.1",
31+
"materialize-css": "^0.97.7",
3032
"preboot": "^4.5.2",
3133
"raw-loader": "^0.5.1",
3234
"rxjs": "5.0.0-beta.12",
@@ -37,8 +39,8 @@
3739
"url-loader": "^0.5.7",
3840
"webpack": "^1.13.2",
3941
"webpack-hot-middleware": "^2.12.2",
40-
"webpack-node-externals": "^1.4.3",
4142
"webpack-merge": "^0.14.1",
43+
"webpack-node-externals": "^1.4.3",
4244
"zone.js": "^0.6.25"
4345
}
4446
}

templates/Angular2Spa/webpack.config.vendor.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ module.exports = {
2424
'@angular/platform-browser-dynamic',
2525
'@angular/router',
2626
'@angular/platform-server',
27+
'angular2-materialize',
2728
'angular2-universal',
2829
'angular2-universal-polyfills',
2930
'bootstrap',
@@ -32,6 +33,7 @@ module.exports = {
3233
'es6-promise',
3334
'event-source-polyfill',
3435
'jquery',
36+
'materialize-css',
3537
'zone.js',
3638
]
3739
},
@@ -42,7 +44,12 @@ module.exports = {
4244
},
4345
plugins: [
4446
extractCSS,
45-
new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery' }), // Maps these identifiers to the jQuery package (because Bootstrap expects it to be a global variable)
47+
new webpack.ProvidePlugin({
48+
$: 'jquery',
49+
jQuery: 'jquery',
50+
'window.jQuery': 'jquery',
51+
Hammer: 'hammerjs/hammer'
52+
}), // Maps these identifiers to the jQuery/Hammer packages (because Materialize/Bootstrap expects them to be global variables)
4653
new webpack.optimize.OccurenceOrderPlugin(),
4754
new webpack.DllPlugin({
4855
path: path.join(__dirname, 'wwwroot', 'dist', '[name]-manifest.json'),

0 commit comments

Comments
 (0)