Permalink
Browse files

Step 2.10: Use TypeScript models

  • Loading branch information...
dotansimha authored and darkbasic committed Jan 24, 2017
1 parent 79e50d5 commit 36f4674de005810d2a2e122ed2559248475c1df5
Showing with 13 additions and 7 deletions.
  1. +13 −7 src/pages/chats/chats.ts
View
@@ -1,26 +1,28 @@
import { Component } from '@angular/core';
import { Observable } from 'rxjs';
import * as moment from 'moment';
import { Chat, MessageType } from '../../models';
@Component({
templateUrl: 'chats.html'
})
export class ChatsPage {
chats: Observable<any[]>;
chats: Observable<Chat[]>;
constructor() {
this.chats = this.findChats();
}
private findChats(): Observable<any[]> {
private findChats(): Observable<Chat[]> {
return Observable.of([
{
_id: '0',
title: 'Ethan Gonzalez',
picture: 'https://randomuser.me/api/portraits/thumb/men/1.jpg',
lastMessage: {
content: 'You on your way?',
createdAt: moment().subtract(1, 'hours').toDate()
createdAt: moment().subtract(1, 'hours').toDate(),
type: MessageType.TEXT
}
},
{
@@ -29,7 +31,8 @@ export class ChatsPage {
picture: 'https://randomuser.me/api/portraits/thumb/lego/1.jpg',
lastMessage: {
content: 'Hey, it\'s me',
createdAt: moment().subtract(2, 'hours').toDate()
createdAt: moment().subtract(2, 'hours').toDate(),
type: MessageType.TEXT
}
},
{
@@ -38,7 +41,8 @@ export class ChatsPage {
picture: 'https://randomuser.me/api/portraits/thumb/women/1.jpg',
lastMessage: {
content: 'I should buy a boat',
createdAt: moment().subtract(1, 'days').toDate()
createdAt: moment().subtract(1, 'days').toDate(),
type: MessageType.TEXT
}
},
{
@@ -47,7 +51,8 @@ export class ChatsPage {
picture: 'https://randomuser.me/api/portraits/thumb/women/2.jpg',
lastMessage: {
content: 'Look at my mukluks!',
createdAt: moment().subtract(4, 'days').toDate()
createdAt: moment().subtract(4, 'days').toDate(),
type: MessageType.TEXT
}
},
{
@@ -56,7 +61,8 @@ export class ChatsPage {
picture: 'https://randomuser.me/api/portraits/thumb/men/2.jpg',
lastMessage: {
content: 'This is wicked good ice cream.',
createdAt: moment().subtract(2, 'weeks').toDate()
createdAt: moment().subtract(2, 'weeks').toDate(),
type: MessageType.TEXT
}
}
]);

0 comments on commit 36f4674

Please sign in to comment.