Skip to content

Commit bf53142

Browse files
committed
Aurelia with an ASP.NET Core API
1 parent df67661 commit bf53142

File tree

10 files changed

+1065
-711
lines changed

10 files changed

+1065
-711
lines changed

ASP.NET Core Basics/src/Aurelia/aurelia_project/aurelia.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
"aurelia-bootstrapper",
9494
"aurelia-dependency-injection",
9595
"aurelia-event-aggregator",
96+
"aurelia-fetch-client",
9697
"aurelia-framework",
9798
"aurelia-history",
9899
"aurelia-history-browser",
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import gulp from 'gulp';
1+
/// <binding AfterBuild='bulid' />
2+
import gulp from 'gulp';
23
import shell from 'gulp-shell';
34

45
gulp.task('bulid', shell.task(['au build']));
Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1+
import { ContactService } from './services/contactService';
2+
13
export class App {
2-
constructor() {
3-
this.message = 'Hello World!';
4-
}
5-
}
4+
static inject() { return [ContactService] };
5+
6+
constructor(contactService) {
7+
this.message = 'Hello World!';
8+
contactService.GetAll()
9+
.then(result => {
10+
this.message = `Contact Results:
11+
${result.map((contact) => contact.name)}`;
12+
});
13+
}
14+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { HttpClient } from 'aurelia-fetch-client';
2+
3+
export class ContactService {
4+
static inject() { return [HttpClient] };
5+
6+
constructor(http) {
7+
this.http = http;
8+
9+
this.http.configure(config => {
10+
config
11+
.useStandardConfiguration()
12+
.withBaseUrl('http://localhost:13322/api/contactsApi/');
13+
});
14+
}
15+
16+
GetAll() {
17+
return this.http.fetch('')
18+
.then(response => response.json())
19+
.catch(error => console.log(error));
20+
}
21+
}

ASP.NET Core Basics/src/Aurelia/wwwroot/_references.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@
1212
/// <reference path="../aurelia_project/tasks/process-css.js" />
1313
/// <reference path="../aurelia_project/tasks/process-markup.js" />
1414
/// <reference path="../aurelia_project/tasks/run.js" />
15+
/// <reference path="../aurelia_project/tasks/test.js" />
1516
/// <reference path="../aurelia_project/tasks/transpile.js" />
1617
/// <reference path="../gulpfile.babel.js" />
1718
/// <reference path="../src/app.js" />
1819
/// <reference path="../src/environment.js" />
1920
/// <reference path="../src/main.js" />
2021
/// <reference path="../src/resources/index.js" />
22+
/// <reference path="../src/services/contactservice.js" />
2123
/// <reference path="js/site.js" />
2224
/// <reference path="lib/bootstrap/dist/js/bootstrap.js" />
2325
/// <reference path="lib/jquery/dist/jquery.js" />
@@ -26,3 +28,4 @@
2628
/// <reference path="scripts/app-bundle.js" />
2729
/// <reference path="scripts/require.js" />
2830
/// <reference path="scripts/text.js" />
31+
/// <reference path="scripts/vendor-bundle.js" />

ASP.NET Core Basics/src/Aurelia/wwwroot/scripts/app-bundle.js

Lines changed: 70 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ASP.NET Core Basics/src/Aurelia/wwwroot/scripts/app-bundle.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)