-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhome.ts
92 lines (69 loc) · 1.51 KB
/
home.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import { Component, ChangeDetectionStrategy } from '@angular/core';
import { NavController, ModalController } from 'ionic-angular';
import { AddItemPage } from '../add-item/add-item';
// MST
import TodoStore, { ITodoStore, ITodoStoreType } from "../../mst-store"
@Component({
changeDetection: ChangeDetectionStrategy.OnPush,
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
public items;
public todoStore: ITodoStoreType
/**
* Creates an instance of HomePage.
* @param {NavController} navCtrl
* @param {ModalController} modalCtrl
* @memberof HomePage
*/
constructor(
public navCtrl: NavController,
public modalCtrl: ModalController,
public _todoStore: TodoStore) {
this.todoStore = _todoStore as ITodoStore
}
ionViewDidLoad() {
this.todoStore.addItem({
title: 'hi1',
description: 'test1',
when: "2018-01-03T02:12:12.766Z"
})
}
/**
*
*
* @memberof HomePage
*/
addItem() {
let addModal = this.modalCtrl.create(AddItemPage);
addModal.onDidDismiss((item) => {
if (item) {
item.when = new Date() + ""
this.todoStore.addItem(item)
}
});
addModal.present();
}
/**
*
*
* @param {any} item
* @memberof HomePage
*/
saveItem(item) {
this.items.push(item);
}
/**
*
*
* @param {any} item
* @memberof HomePage
*/
deleteItem(item) {
console.log(item)
this.todoStore.deleteItem(item)
}
viewItem(item) {
}
}