We are showing events in a normal html table using angular js. The table will be like as shown below
*-------------------------------*
| Time | Name |
*-------*-----------------------*
| 07:00 | xxxxxxxxxxx |
|-------| |
| 07:15 | |
|-------|-----------------------|
| 07:30 | xxxxxxxxxxxxxx |
|-------|-----------------------|
| 07:45 | |
|-------|-----------------------|
| 08:00 | |
|-------|-----------------------|
| 08:15 | xxxxxxxxxxxxxx |
|-------|-----------------------|
and if i click hide free slots it should hide all free columns and show like given below. if the row is merged , for example 07,07:15 , it should show only the first row. (hide all with type = Free in json )
*-------------------------------*
| Time | Name |
*-------*-----------------------*
| 07:00 | xxxxxxxxxxx |
|-------|-----------------------|
| 07:30 | xxxxxxxxxxxxxx |
|-------|-----------------------|
| 08:15 | xxxxxxxxxxxxxx |
|-------|-----------------------|
Code
App.js
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
$scope.array = [
{ "StartTime": "07:00", "Type":"Booked", "Name": "xxxxxxxx", "Slots": ["07:00","07:15"] },
{ "StartTime": "07:30", "Type":"Blocked", "Name": "xxxxxxxx", "Slots": ["07:30"] },
{ "StartTime": "07:45", "Type":"Free", "Slots": ["07:45"] },
{ "StartTime": "08:00", "Type":"Free", "Slots": ["80:00"] },
{ "StartTime": "08:15", "Type":"Booked", "Name": "xxxxxxxx", "Slots": ["08:15"] }
];
});
index.html
<!DOCTYPE html>
<html ng-app="plunker">
<head>
<script data-require="angular.js@*" data-semver="1.3.6" src="https://code.angularjs.org/1.3.6/angular.js"></script>
<link rel="stylesheet" href="style.css" />
<script src="app.js"></script>
</head>
<body ng-Controller="MainCtrl">
<table border="1">
<thead>
<tr>
<th>Time</th>
<th>Name</th>
</tr>
</thead>
<tbody>
<tr ng-repeat-start="item in array">
<td>{{item.Slots[0]}}</td>
<td rowspan="{{item.Slots.length}}">{{item.Name}}</td>
</tr>
<tr ng-repeat="slot in item.Slots" ng-if="!$first" ng-repeat-end>
<td>{{slot}}</td>
</tr>
</tbody>
</table>
</body>
</html>
Plunker Link
ng-ifto combine with whatever button you are planning to add...