0

I created a rest web api and using AngularJS, I want to receive those json data and store them in a table. I am new to AngularJS. I was able to get all the json data but I want to split them up into each row. I am not sure if I am doing to correctly or not but here is my code:

index.html

<!DOCTYPE html>
<html ng-app="demoApp">
<head>
<meta charset="UTF-8">
<title>Angular</title>
<script src="lib/angular.js"></script>
<script src="angularDemo.js"></script>
</head>
<body>
    <div ng-controller="demoController">
        <table>
            <tr>
                <th>Id</th>
                <th>Question</th>
            </tr>
            <tr ng-repeat=" quiz values">
                <td>{{result.id}}</td> <!-- Does not get any value-->
                <td>{{result.question}}</td> <!-- Does not get any value-->
            </tr>
        </table>
        <h1>{{result}}</h1> <!-- gets all the json data -->
    </div>
</body>
</html>

js

var app = angular.module("demoApp", []);

app.controller("demoController", function($scope, $http) {
    $http.get("http://localhost:8080/quiz/webapi/quiz")
    .then(function(response) {
        $scope.result = response.data;
    });
});
1
  • What is this <tr ng-repeat=" quiz values">? Commented Aug 16, 2017 at 15:21

1 Answer 1

1

Your ng-repeat is not good,

If i understand your array of results is in $scope.result, so you have to do this kind of ng-repeat :

<tr ng-repeat="row in result">
   <td>{{row.id}}</td> 
   <td>{{row.question}}</td> 
</tr>
Sign up to request clarification or add additional context in comments.

1 Comment

Oh ok I thought after ng-repeat="", it is supposed to be some kind of comments. Now I see, thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.