1

I have updated the code and the output I am getting like this:

Updated

So in the output table, endTime, period and monday are headers. For EndTime I want to display only endtime of the monday array but it is displaying an entire array. How do I specifically display only endTime data. Same goes for period.

Here is the plunker Timetable

Where am I going wrong?

Index.view.html

  <table class="table table-bordered">
    <tr>
      <th class="endTime" ng-model="monday.endTime">End Time</th>
      <td ng-repeat="d in data track by $index">{{d}}</td>
    </tr>
    <tr>
      <th class="period" ng-model="monday.period">Peroid</th>
      <td ng-repeat="d in data track by $index">{{d}}</td>
    </tr>

    <tr><th class="days">Monday</th></tr>
  </table>

Index.controller.js

        .controller('Admin.IndexController',function($scope,$http,$location,$rootScope,fileUpload)
    {                         
       $scope.college_id='583b01ce6864990011c12ec6';
        var i =0;       
        $http.get('https://student.herokuapp.com/college/'+$scope.college_id)
        .success(function(response){
             // for(var i=0;i<tableLen;i++){
                console.log(response.college);
            $scope.data = response.college.timeTableTemplate;
            console.log($scope.data);
         });           

        })

JSON Array

    "monday": [
    {
      "endTime": "08:50 AM",
      "startTime": "08:00 AM",
      "duration": "50",
      "period": "A"
    },
    {
      "endTime": "08:50 AM",
      "startTime": "08:00 AM",
      "duration": "50",
      "period": "A"
    }
13
  • Where you added ng-repeat directive? Commented Dec 27, 2016 at 11:43
  • I did add the ng-repeat but didnt get the desired results. Commented Dec 27, 2016 at 11:45
  • 1
    If you can add plunkr or jsfiddle, it will be faster for you to get this answered. Commented Dec 27, 2016 at 11:46
  • Desired results means you want vertical rows correct? Commented Dec 27, 2016 at 11:47
  • @AnuragSinha Ok I will add it Commented Dec 27, 2016 at 11:47

1 Answer 1

1

First of all change your json structure to in this type

{  
  "endTime": ["08:50 AM", "08:50 AM", "08:50 AM"],
  "startTime": "[08:00 AM, 08:00 AM, 08:00 AM]",
  "duration": ["50", "50", "50"],
  "period": ["A", "A", "A"]
}

I create a plunker there you can see I got the data from json and display in table tag. Please read this and apply in your code.

 <table class="table table-bordered">
    <tr>
      <th>Id</th>
      <th>First Name</th>
      <th>Last Name</th>
    </tr>
    <tr ng-repeat="d in data">
      <td >{{ d.id }}</td>
      <td >{{ d.firstName }}</td>
      <td >{{ d.lastName }}</td>
    </tr>
  </table>

Plunker

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

8 Comments

Hi Thank you for the efforts. I see that headers is in horizontal format. I made them in vertical format but unable to include the data with related headers. Check the plunk.
I am updating my plunker. please check this.
Thank you. I checked it and when I used the code, I could see the value in response and but not in $scope.data during debug. Any reason?
value also in $scope.data. You can console the value of $scope.data and if it is helpful and click right of this answer.
data.endTime and data.period works in plnkr but not working with my code and when i remove the endTime and period entire json data is printed.
|

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.