Http provider data transfer from json


#1

hello

My json data provider like this

import { Injectable } from ‘@angular/core’;
import { Http } from ‘@angular/http’;
import ‘rxjs/add/operator/map’;

@Injectable()
export class Deneme {

constructor(public http: Http) {
console.log(‘Hello Deneme Provider’);
}

loading(){

return this.http.get(‘assets/data/datadic.json’).map(res=>res.json());
}

}

My compenant is like this

import { Component } from ‘@angular/core’;
import { NavController, NavParams } from ‘ionic-angular’;
import {Deneme} from ‘…/…/providers/deneme’;

@Component({

templateUrl: ‘dic.html’

})
export class DicPage {

veri=[];

constructor(public navCtrl: NavController, public navParams: NavParams,public den:Deneme) {

}

ionViewDidLoad(){

this.den.loading().subscribe(data => {this.veri=data});
console.log(this.veri);

}

}

my console output

Hello Deneme Provider
lang.js:88 Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode.
hello
[]

as you see my veri array is empty why ? any idea

Thank you