How to attach a json file to the .js file


#1

I want to connect the ,json file with a .js file in my ionic 2 project and show the data using the .html.(using ngFor)
Please tell me the syntax for that.


#2

you should use Http, HTTP_PROVIDERS provider from angular2.

https://angular.io/docs/js/latest/api/http/Http-class.html


#3

Thanks Sir…:smiley:
can you tell me from where to import http_providers in ionic 2 …is it same as the example in the link?


#4

can you please provide a simple code snipett in which we get data from json file and show them using .html
please it will be a great help sir.


#5
exports.config = {
    data: {
        "name": "aaron"
    }
}

in code

var config = require('./data/something')