-- 第七课:重用组件
import { Component } from '@angular/core';
import { NavController, AlertController, Platform } from 'ionic-angular';
import { ChecklistPage } from '../checklist/checklist';
import { ChecklistModel } from '../../models/checklist-model';
import { Keyboard } from 'ionic-native';
import { Data } from '../../providers/data';
@Component({
selector: 'page-quicklistshome',
templateUrl: 'quicklistshome.html'
})
export class QuickListsHomePage {
checklists: ChecklistModel[] = [];
local: Storage;
constructor(public nav: NavController, public platform: Platform, public dataService: Data, public alertCtrl: AlertController) {
}
ionViewDidLoad(){
this.platform.ready().then(() => {
this.dataService.getData().then((checklists) => {
let savedChecklists: any = false;
if(checklists && typeof(checklists) != "undefined"){
savedChecklists = JSON.parse(checklists);
}
if(savedChecklists){
savedChecklists.forEach((savedChecklist) => {
let loadChecklist = new ChecklistModel(savedChecklist.title, savedChecklist.items);
this.checklists.push(loadChecklist);
loadChecklist.checklist.subscribe(update => {
this.save();
});
});
}
});
});
}
}Last updated
