Skip to content

Commit 669390f

Browse files
committed
2 parents 4bc25e3 + aa0380c commit 669390f

File tree

14 files changed

+576
-492
lines changed

14 files changed

+576
-492
lines changed

ASP.NET Core Basics/src/Aurelia/Controllers/HomeController.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ public IActionResult Contact()
2727
return View();
2828
}
2929

30+
public IActionResult Aurelia()
31+
{
32+
return View();
33+
}
34+
3035
public IActionResult Error()
3136
{
3237
return View();
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div aurelia-app="main">
2+
<script src="/scripts/vendor-bundle.js" data-main="aurelia-bootstrapper"></script>
3+
</div>

ASP.NET Core Basics/src/Aurelia/Views/Shared/_Layout.cshtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
<div class="navbar-collapse collapse">
3232
<ul class="nav navbar-nav">
3333
<li><a asp-area="" asp-controller="Home" asp-action="Index">Home</a></li>
34+
<li><a asp-area="" asp-controller="Home" asp-action="Aurelia">Aurelia</a></li>
3435
<li><a asp-area="" asp-controller="Home" asp-action="About">About</a></li>
3536
<li><a asp-area="" asp-controller="Home" asp-action="Contact">Contact</a></li>
3637
</ul>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"id": "aspnetcore",
5353
"displayName": "ASP.NET Core",
5454
"output": "wwwroot\\scripts",
55-
"baseUrl": "scripts"
55+
"baseUrl": "../scripts"
5656
}
5757
],
5858
"loader": {
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
<template>
2-
<h1>${message}</h1>
2+
<require from="./contacts/contact-list"></require>
3+
<h1>App</h1>
4+
<contact-list></contact-list>
35
</template>
Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,2 @@
1-
import { ContactService } from './services/contactService';
2-
31
export class App {
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-
}
142
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<template>
2+
<ul>
3+
<li repeat.for="contact of contacts">
4+
<h4>${contact.name}</h4>
5+
<p>${contact.getAddress()}</p>
6+
</li>
7+
</ul>
8+
</template>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { ContactService } from './contact-service';
2+
3+
export class ContactList {
4+
static inject() { return [ContactService] };
5+
6+
constructor(contactService) {
7+
this.contactService = contactService;
8+
this.contacts = [];
9+
}
10+
11+
created() {
12+
this.contactService.GetAll()
13+
.then(contacts => this.contacts = contacts);
14+
}
15+
}

ASP.NET Core Basics/src/Aurelia/src/services/contactService.js renamed to ASP.NET Core Basics/src/Aurelia/src/contacts/contact-service.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { HttpClient } from 'aurelia-fetch-client';
2+
import { Contact } from './contact';
23

34
export class ContactService {
45
static inject() { return [HttpClient] };
@@ -16,6 +17,7 @@ export class ContactService {
1617
GetAll() {
1718
return this.http.fetch('')
1819
.then(response => response.json())
20+
.then(contacts => Array.from(contacts, c => new Contact(c)))
1921
.catch(error => console.log(error));
2022
}
2123
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export class Contact {
2+
constructor(data) {
3+
Object.assign(this, data);
4+
}
5+
6+
getAddress() {
7+
return `${this.address} ${this.city}, ${this.state} ${this.postalCode}`;
8+
}
9+
}

0 commit comments

Comments
 (0)