Consuming Json from an aquivo

Asked

Viewed 71 times

0

good morning,I created a JSON file and I’m having difficulty listing the data from it, I can from the controller, but I would like it to be displayed from the json, how should I proceed ?

  • 2

    You can show the code where you need to use JSON?

  • I am studying angular and created a JSON file and would like you to display on the table how to do this

  • Welcome to Stack Overflow, Luciano! Please edit your question, and include the code from where you are having trouble (the more information you give, the easier/faster you will get an answer) - do the tour to get to know the site better, and read here on how to prepare a more complete question.

1 answer

0

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

You can do 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, of where the JSON file is.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.