Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class App {
title: 'Contact List'
},
{
route: 'contact-detail/:id',
route: 'contact-detail/:id?',
name: 'contactdetail',
moduleId: '../contacts/contactDetail',
nav: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ <h1>Contact Details</h1>
<dd>${contact.email}</dd>
</dl>
</div>
<h3 if.bind="!hasContactId">
Place holder for creating a new contact
</h3>
<a route-href="route: contactlist">Back to List</a>
<hr />
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,20 @@ import { ContactService } from './contactService';
@inject(ContactService)
export class ContactDetail {
contact: Contact;
hasContactId: boolean;

constructor(private contactService: ContactService) { }

activate(parms, routeConfig) {
return this.contactService.getById(parms.id)
.then(contact => this.contact = contact);
this.hasContactId = parms.id;

if (this.hasContactId) {
return this.contactService.getById(parms.id)
.then(contact => this.contact = contact);
}

return null;

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<h1>Contact List</h1>

<p if.bind="!contacts"><em>Loading...</em></p>

<a route-href="route: contactdetail">Create New Contact</a>

<table class="table" if.bind="contacts">
<thead>
Expand Down