-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3f22bcb
commit cfe5ba2
Showing
6 changed files
with
66 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
ContactsManager/src/components/display-contacts/display-contacts.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.mdl-card { | ||
width: 320px; | ||
height: 320px; | ||
} | ||
|
||
.mdl-card > .mdl-card__title { | ||
background: #FF5252; | ||
color: #fff; | ||
/*background: url('./images/image_card.jpg') bottom right 15% no-repeat #46B6AC;*/ | ||
} |
37 changes: 18 additions & 19 deletions
37
ContactsManager/src/components/display-contacts/display-contacts.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,23 @@ | ||
import {Component} from "angular2/core"; | ||
import {Contact} from "../../models/contact"; | ||
import {ContactsList} from "../../mock-contacts"; | ||
import { Component, OnInit } from "angular2/core"; | ||
import { Contact } from "../../models/contact"; | ||
import { ContactsService } from "../../services/contacts/contacts.service"; | ||
|
||
@Component({ | ||
selector: 'display-contacts', | ||
templateUrl:'/src/components/display-contacts/display-contacts.html', | ||
styles: [` | ||
.mdl-card { | ||
width: 320px; | ||
height: 320px; | ||
} | ||
templateUrl:'src/components/display-contacts/display-contacts.html', | ||
styleUrls: ['src/components/display-contacts/display-contacts.css'] | ||
}) | ||
export class DisplayContactsComponent implements OnInit { | ||
|
||
contactsList: Contact[]; | ||
|
||
.mdl-card > .mdl-card__title { | ||
background: #FF5252; | ||
color: #fff; | ||
/*background: url('./images/image_card.jpg') bottom right 15% no-repeat #46B6AC;*/ | ||
} | ||
`] | ||
}) | ||
export class DisplayContactsComponent { | ||
contactsList: Contact[] = ContactsList; | ||
} | ||
constructor(private _contactsService: ContactsService) {} | ||
|
||
getContacts() { | ||
this._contactsService.getContacts().then(contacts => this.contactsList = contacts); | ||
} | ||
|
||
ngOnInit() { | ||
this.getContacts(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Injectable } from 'angular2/core'; | ||
import { ContactsList } from "../../mock-contacts"; | ||
import { Contact } from "../../models/contact"; | ||
|
||
@Injectable() | ||
export class ContactsService { | ||
|
||
getContacts() { | ||
return Promise.resolve(ContactsList); | ||
} | ||
|
||
getContactsSlowly() { | ||
return new Promise<Contact[]>(resolve => setTimeout(() => resolve(ContactsList), 2000)); | ||
} | ||
|
||
addContact(_contact:Contact) { | ||
if(_contact) { | ||
ContactsList.push(_contact); | ||
} | ||
} | ||
|
||
} |