import { Component } from '@angular/core' ; import { IonicPage , NavController } from 'ionic-angular' ; import { Storage } from "@ionic/storage" ; import { LnLoadingController } from "../../common/ln-loading-controller" ; import { Novel } from "../../common/models/novel" ; import { RecentNovelsService } from "../../providers/recent-novels-service" ; @ IonicPage ( ) @ Component ( { selector : 'page-ln-recent-novels' , templateUrl : 'ln-recent-novels.html' , styles : [ 'ln-recent-novels.scss' ] } ) export class LnRecentNovelsPage { novels : Array < Novel > ; constructor ( public navCtrl , public recentNovelsService , private loadingCtrl , private storage ) { } ionViewDidLoad ( ) { console . log ( 'ionViewDidLoad LnRecentNovelsPage' ) ; this . updateNovelList ( ) ; } updateNovelList ( ) { this . loadingCtrl . presentLoadingMessage ( ) ; return new Promise ( ( resolve ) => { this . recentNovelsService . getNovels ( ) . then ( ( novels ) => { this . novels = novels ; this . loadingCtrl . hideLoadingMessage ( ) ; resolve ( ) ; } ) . catch ( ( ) => { this . loadingCtrl . hideLoadingMessage ( ) ; } ) ; } ) ; } }