JavaScript AngularJS ng-repeat-start ng-repeat-end with table and rowspan angularjs repeat start end,angularjs repeat start,angularjs ng-repeat-

I am facing issue while making a dynamic table with dynamic rowspan. My json is a array of objects. And the element objects are also arrays. The element arrays should come as the no of dynamic rowspan. I have a json like:

{
  "roleTypes": [
    {
      "roleType": {
        "name": "SOA Role"
      },
      "rates": [
        {
          "rateType": {
            "name": "new Rate"
          },
          "hourlyRate": {
            "value": 1222
          },
          "internalRate": {
            "value": 433
          }
        },
        {
          "rateType": {
            "name": "myRate"
          },
          "hourlyRate": {
            "value": 1350
          },
          "internalRate": {
            "value": 1650
          }
        }
      ]
    },
    {
      "roleType": {
        "name": "SOA Role"
      },
      "rates": [
        {
          "rateType": {
            "name": "new Rate"
          },
          "hourlyRate": {
            "value": 1222
          },
          "internalRate": {
            "value": 433
          }
        },
        {
          "rateType": {
            "name": "myRate"
          },
          "hourlyRate": {
            "value": 1350
          },
          "internalRate": {
            "value": 1650
          }
        }
      ]
    },
    {
      "roleType": {
        "name": "AngularJs Developer"
      }
    }
  ]
}

if I want to use ng-repeat-start and ng-repeat-end and make a table structure like below:

roleType------      | rateType-----hourlyRate--------internalRate
---------------------------------------------------------------------------
                    | new Rate      1222                433
                    ---------------------------------------------------
SOA Role            | myRate        1350                1650
---------------------------------------------------------------------------
                    | new Rate      1222                 433
                    ---------------------------------------------------
AngularJs Developer |myRate         1350                 1650
---------------------------------------------------------------------------

I am struggling to get the dynamic rowspan. Please check if anyone can help.

Answer:1

What Pankaj mentioned is correct but I think you need a more dynamic table on rowspan. You can do like as the following example:

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

app.controller("FooController", function($scope) {

  $scope.data = {
    "roleTypes": [{
      "roleType": {
        "name": "SOA Role"
      },
      "rates": [{
        "rateType": {
          "name": "new Rate"
        },
        "hourlyRate": {
          "value": 1222
        },
        "internalRate": {
          "value": 433
        }
      }, {
        "rateType": {
          "name": "myRate"
        },
        "hourlyRate": {
          "value": 1350
        },
        "internalRate": {
          "value": 1650
        }
      }]
    }, {
      "roleType": {
        "name": "AngularJs Developer"
      },
      "rates": [{
        "rateType": {
          "name": "new Rate"
        },
        "hourlyRate": {
          "value": 123
        },
        "internalRate": {
          "value": 1431
        }
      }, {
        "rateType": {
          "name": "myRate"
        },
        "hourlyRate": {
          "value": 443
        },
        "internalRate": {
          "value": 1930
        }
      }, {
        "rateType": {
          "name": "otherRate"
        },
        "hourlyRate": {
          "value": 343
        },
        "internalRate": {
          "value": 2000
        }
      }]
    }]
  };
});
td[rowspan] {
  vertical-align: middle !important;
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>

<link rel="stylesheet" target='_blank' href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">


<div ng-app="sa" ng-controller="FooController">
  <table class="table table-bordered">
    <thead>
      <tr>
        <th>roleType</th>
        <th>rateType</th>
        <th>hourlyRate</th>
        <th>internalRate</th>
      </tr>
    </thead>

    <tbody>
      <tr ng-repeat-start="role in data.roleTypes">
        <td rowspan="{{role.rates.length}}">{{role.roleType.name}}</td>
        <!-- Display the first rate in the same "tr" -->
        <td>{{role.rates[0].rateType.name}}</td>
        <td>{{role.rates[0].hourlyRate.value}}</td>
        <td>{{role.rates[0].internalRate.value}}</td>
      </tr>
      
      <!-- Now display the other rates in different "tr" excluding first -->
      <!-- You can also make a subarray from here excluding the 1st rate -->
      <tr ng-repeat="rate in role.rates" ng-if="!$first" ng-repeat-end>
        <td>
          {{rate.rateType.name}}
        </td>
        <td>
          {{rate.hourlyRate.value}}
        </td>
        <td>
          {{rate.internalRate.value}}
        </td>
      </tr>
    </tbody>
  </table>
</div>
Answer:2

I have to display the content in a grid. All items are div's with random height, and I need to have control over how they are displayed. It is a responsive UI with 4-cols, 3-cols and 1-cols. Assume ...

I have to display the content in a grid. All items are div's with random height, and I need to have control over how they are displayed. It is a responsive UI with 4-cols, 3-cols and 1-cols. Assume ...

  1. position div at bottom of parent
  2. position div in center
  3. position div at bottom of page
  4. position div relative to another div
  5. position div on top of another
  6. position div below another div
  7. position divided by time
  8. position divs side by side
  9. position div to right
  10. position div relative to parent
  11. position div in center of screen
  12. position div in center of parent
  13. position div bottom right of parent
  14. position div at bottom of screen
  15. position div inside div
  16. position div over image
  17. position div at top of page
  18. position div vertically center
  19. position div to right of another div
  20. position div at bottom of div

There are null and undefined in JavaScript. Are there any meaningful use cases of assigning undefined to a variable?

There are null and undefined in JavaScript. Are there any meaningful use cases of assigning undefined to a variable?

Input: seconds, Output: grammatically correct, formatted time (with words spelled out). So far I managed to get as far as going from say 40044373 to 1 year, 98 days, 5 hours, 37 minutes, 1 second - ...

Input: seconds, Output: grammatically correct, formatted time (with words spelled out). So far I managed to get as far as going from say 40044373 to 1 year, 98 days, 5 hours, 37 minutes, 1 second - ...

  1. commas right now

I searched for a solution of passing a get variable obtained from index.php page to included.php file[ loaded by javascript ]. A nice solution by php require function is given Pass and print a $_GET ...

I searched for a solution of passing a get variable obtained from index.php page to included.php file[ loaded by javascript ]. A nice solution by php require function is given Pass and print a $_GET ...