S
S
Semyon Kataparov2016-04-24 17:30:15
Angular
Semyon Kataparov, 2016-04-24 17:30:15

How to output information received in json in angular.js via foreach?

How to output information received in json in angular.js via foreach?
app.js:

//Код сверху

$scope.npq = $http.get('json/items.json');

//Код снизу

index.php:
<table ng-repeat="item in npq.items">
            <tr>
                <td>
                    <h1>{{ item.name }}</h1>
                </td>
            </tr>
        </table>

items.json:
{
  "items": [
    {
      "name": "M4A1-S | Hyper Beast",
      "price": "7",
      "quality": "Battle-Scared"
    }
  ]
}

Outputs nothing. How to fix?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2016-04-24
Protko @Fesor

Outputs nothing. How to fix?

First, let's go and read the documentation. And then we think. You should pay special attention to "promises" (this is not tied to angular in any way) and work with non-blocking API calls.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question