ricksantiago

Untitled

May 23rd, 2018
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { Component } from '@angular/core';
  2. import { NavController, LoadingController, AlertController } from 'ionic-angular';
  3. import { NavLifeCycles } from '../../utils/ionic/nav/nav-lifecycles';
  4. import { AgendaReuniao } from '../../modelos/agendarReuniao';
  5. import { AgendaReuniaoServiceProvider } from '../../providers/agenda-reuniao-service/agenda-reuniao-service';
  6. import { HttpErrorResponse } from '@angular/common/http';
  7.  
  8. @Component({
  9.   selector: 'page-home',
  10.   templateUrl: 'home.html',
  11.   providers: [AgendaReuniaoServiceProvider]
  12. })
  13.  
  14. export class HomePage implements NavLifeCycles {
  15.  
  16.   public agendaReuniaoList: AgendaReuniao[];
  17.  
  18.   constructor(
  19.     public navCtrl: NavController,
  20.     private _loadingCtrl: LoadingController,
  21.     private _alertCtrl: AlertController,
  22.     private _agendaService: AgendaReuniaoServiceProvider) {}
  23.  
  24.     ionViewDidLoad(){
  25.  
  26.       let loading = this._loadingCtrl.create({
  27.         content: "Carregando Agendamentos"
  28.       });
  29.       loading.present();
  30.  
  31.       this._agendaService.listaAgendamentos().subscribe(
  32.  
  33.        data => {
  34.  
  35.             const response = (data as any)
  36.             const objeto_retorno = JSON.parse(JSON.stringify(response._body));
  37.  
  38.             this.agendaReuniaoList = objeto_retorno.results;
  39.  
  40.             console.log("OBJETO DA VARIAVEL! " + this.agendaReuniaoList);
  41.             console.log("OBJETO DO DADO! " + data)
  42.             console.log("OBJETO DO RETORNO! " + objeto_retorno);
  43.  
  44.             loading.dismiss();
  45.         },
  46.         (err: HttpErrorResponse) => {
  47.  
  48.           console.log("Erro: " + err.status)
  49.           loading.dismiss();
  50.  
  51.           this._alertCtrl.create({
  52.             title: "Falha na conexão",
  53.             subTitle: "Não foi possivel carregar a lista de agendamentos, tente novamente mais tarde!",
  54.             buttons: [
  55.               { text: 'Certo'}
  56.             ]
  57.           }).present()
  58.         }
  59.       );
  60.     }
  61.  
  62. }
Add Comment
Please, Sign In to add comment