JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://underscorejs.org/underscore.js"></script>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css">
<br />
<br />
<div ng-app="myApp">
<div ng-controller="TableCtrl">
<div class="input-group">
<input class="form-control" ng-model="searchText" placeholder="Type anything | Search anything" type="search" ng-change="search()" /> <span class="input-group-addon">
<span class="glyphicon glyphicon-search"></span>
</span>
</div>
<table class="table table-hover data-table myTable">
<thead>
<tr>
<th class="EmpId"> <a href="#" ng-click="sort('EmpId',$event)" >EmpId
<span class="{{Header[0]}}"></span>
</a>
</th>
<th class="name"> <a ng-click="sort('name')" href="#"> Name
<span class="{{Header[1]}}"></span></a>
</th>
<th class="Email"> <a ng-click="sort('Email')" href="#"> Email
<span class="{{Header[2]}}"></span></a>
</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in ItemsByPage[currentPage] | orderBy:columnToOrder:reverse">
<td>{{item.EmpId}}</td>
<td>{{item.name}}</td>
<td >
<p ng-hide="show">
{{ item.Email | limitTo: 50 }}... | <a ng-click="show = true">Pokračovat</a>
</p>
<p ng-show="show">
{{ item.Email }} | <a ng-click="show = false">Zavřít</a>
</p>
</td>
</tr>
</tbody>
</table>
...
CSS
.icon-search {
margin-left:-25px;
}
th {
width: 33%;
text-align: center;
}
.hide {
}
JavaScript
//Demo of Searching Sorting and Pagination of Table with AngularJS - Advance Example
var myApp = angular.module('myApp', []);
//Not Necessary to Create Service, Same can be done in COntroller also as method like add() method
myApp.service('filteredListService', function () {
this.searched = function (valLists,toSearch) {
return _.filter(valLists,
function (i) {
/* Search Text in all 3 fields */
return searchUtil(i, toSearch);
});
};
this.paged = function (valLists,pageSize)
{
retVal = [];
for (var i = 0; i < valLists.length; i++) {
if (i % pageSize === 0) {
retVal[Math.floor(i / pageSize)] = [valLists[i]];
} else {
retVal[Math.floor(i / pageSize)].push(valLists[i]);
}
}
return retVal;
};
});
var TableCtrl = myApp.controller('TableCtrl', function ($scope, $filter, filteredListService) {
$scope.pageSize = 9;
$scope.allItems = getDummyData();
$scope.reverse = false;
$scope.resetAll = function () {
$scope.filteredList = $scope.allItems;
$scope.newEmpId = '';
$scope.newName = '';
$scope.newEmail = '';
$scope.searchText = '';
$scope.currentPage = 0;
$scope.Header = ['','',''];
}
$scope.add = function () {
$scope.allItems.push({
EmpId: $scope.newEmpId,
name: $scope.newName,
Email: $scope.newEmail
});
$scope.resetAll();
}
$scope.search = function () {
$scope.filteredList =
filteredListService.searched($scope.allItems, $scope.searchText);
if ($scope.searchText == '') {
$scope.filteredList = $scope.allItems;
}
$scope.pagination();
}
// Calculate Total Number of Pages based on Search Result
$scope.pagination =...