0

I am trying to display the JSON object in JSP page using angular js. The Data is coming correctly but display code is not working properly in JSP page.

in app.js

 $http.get(urlBase+'/users1').success(function (data){


for(var i=0;i<data.length;i++){

    alert(data[i]);



}

$scope.users=data;

 })
 .error(function(data) {
     alert("errore"+data);
     $scope.data = "error in fetching data";
 });

jsp file

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"

    pageEncoding="ISO-8859-1"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html ng-app="taskManagerApp">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title>AngularJS Task Manager</title>

<script data-require="angular.js@*" data-semver="1.2.13" src="http://code.angularjs.org/1.2.13/angular.js"></script>

<script src="<c:url value="/resources/js/app.js"/>"></script>
</head>

<body>

<div ng-controller="taskManagerController">



   <span>Add Task</span>


  <div>

   <div>

    <table>

     <tr>

      <td> Name:</td>

      <td><input type="text" ng-model="Name"/></td>

     </tr>

     <tr>

      <td>City:</td>

      <td><input type="text" ng-model="City"/></td>

     </tr>


     <tr>

      <td>

<button ng-click="addTask()" class="btn-panel-big">Add New Task</button></td>

     </tr>

    </table>        

   </div>

  </div>


  <div>
  <table>
     <div ng-repeat="user in users">

     <tr>
     <td>hai  {{user.id}}</td>
     <td>hello  {{user.Name}}</td>
     <td>wellcome  {{user.city}}</td>

     </tr>

     </div>
  </table>

  </div>


  </div>


</body>

</html>

ng-repeat is also not working here. Is there any mistake while assigning the value to scope variable? Can anyone help me to fix this?

1
  • 2
    use the ng-repeat inside tr instead of div Commented Jul 11, 2017 at 7:50

1 Answer 1

1

ng-repeat="user in users" should be added to the tr tag and not the div tag.

Sign up to request clarification or add additional context in comments.

Comments

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.