Advertisement
rodrigofbm

home-service.ts

Apr 7th, 2017
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { Injectable } from '@angular/core';
  2. import { Http } from '@angular/http';
  3. import 'rxjs/add/operator/map';
  4.  
  5. @Injectable()
  6. export class HomeService {
  7.   public data: any;
  8.   public api_url: string;
  9.  
  10.   constructor(public http: Http) {
  11.     this.api_url = 'https://segredosuesc.herokuapp.com';
  12.   }
  13.  
  14.  
  15.   // Carrega a listagem de Fotos
  16.   load() {
  17.     return new Promise(resolve => {
  18.       this.http.get(this.api_url + '/segredos/')
  19.         .map(res => res.json())
  20.         .subscribe(data => {
  21.           this.data = data;
  22.           console.log(data);
  23.           resolve(this.data);
  24.  
  25.          
  26.         });
  27.     });
  28.  
  29.  
  30.   }
  31.  
  32.  
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement