ionic framework - fetching data from json file in assets folder -


trying fetch data json file in ionic 2 application, using below piece of code within constructor fetching json assets folder, getting error "supplied parameters not match signature of call target." missing, please suggest.

this.http.get('assets/sample.json')  .map((res) => res.json().records)  .subscribe(data => {  this.data = data;  console.log("json data"+ data);  }, (rej) => {console.error("could not load local data",rej)});

so solved it, path of json file assets folder used below me answer displayed data on device.

 this.http.get('/android_asset/www/assets/data/subjects.json').map(res => res.json()).subscribe(      response => {          this.posts = response;  		console.log(this.posts);      },      err => {          console.log("oops!");      }); 

while if use /assets/data/subjects.json, display data on browser, though can not use single path able data on both browser on device, because both have different file system need different way access data on devices.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -