Consuming Json from a file

0

Hello, I created a JSON file and I'm having trouble listing the data from it, I can get it from the controller, but I want it to be displayed from json, how should I proceed?

    
asked by anonymous 11.06.2017 / 15:19

1 answer

0

The request to read data from a JSON file basically works as a GET request for a backend application API.

You can do it inside a factory:

function recuperar(){
    return $http.get("api/arquivo.json").then(function(resposta){
        service.arquivo = resposta.data;
    });
};

Where "api / file.json" is the address, from the root of your project, where the JSON file is.

    
13.06.2017 / 22:19