I can't I get the value of the get subscribe data out of the function


#1

My article.ts code:
I can’t I get the value of the get subscribe data out of the function getPost()

import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { ArticleServiceProvider } from '../../providers/article-service/article-service';
import { Http, Response } from '@angular/http';
//import 'rxjs/add/operator/then';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/catch';
import { Observable } from 'rxjs/Observable';

/**
 * Generated class for the ArticlePage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

 @IonicPage()
 @Component({
 	selector: 'page-article',
 	templateUrl: 'article.html',
 })
 export class ArticlePage {
 	article: {};
 	constructor(public navCtrl: NavController, public navParams: NavParams, private articleService: ArticleServiceProvider, private http: Http) {
 		var id = navParams.data.id;
 		this.article = this.getPost();
 		console.log('article id: '+navParams.data.id);
 		console.log('constructor', this.article);
 	}

 	ionViewDidLoad() {
 		console.log('ionViewDidLoad ArticlePage');
 	}

 	getPost(){
 		return this.http.get("http://localhost/bbntimes/api.php?function=articleById&id=405")
 		.do((res: Response) => console.log(res.json()))
 		.map((res : Response ) => res.json())
 		.subscribe(data => this.article = data)
 		.catch(error => Observable.throw(error.json().error || "Server error"))
 	}
 }