Skip to main content

Sorting table with angular


Below is a demo of sorting a table with Angular.
-----------



table will be ordered by {{orderBy}}

name age gender email salary
{{employee.name}} {{employee.age}} {{employee.gender}} {{employee.email}} {{employee.salary}}
-----
codes
-----
<!DOCTYPE html>
<html ng-app="myModule">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>hello world</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script type="text/javascript" src="sj.js"></script>
<style>
table {
border-collapse: collapse;
}
table, td, th {
border: 1px solid black;
padding: 4px;
}
</style>
</head>
<body ng-controller="myController">
<div><h1>Employees</h1></div>
<div>
<select name="order by" ng-model="orderBy">
<option value="name">Name</option>
<option value="age">Age</option>
<option value="com">company</option>
<option value="-salary">Salary DEC</option>
</select>
<p>table will be ordered by {{orderBy}}</p>
<br><br>
</div>
<div>
<table>
<thead>
<tr>
<th>name</th>
<th>age</th>
<th>eyecolor</th>
<th>gender</th>
<th>com</th>
<th>email</th>
<th>salary</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="employee in employees | orderBy:orderBy">
<td> {{employee.name}} </td>
<td>{{employee.age}}</td>
<td>{{employee.eyecolor}}</td>
<td>{{employee.gender}}</td>
<td>{{employee.com}}</td>
<td>{{employee.email}}</td>
<td>{{employee.salary}}</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
view raw hello.html hosted with ❤ by GitHub
angular
.module("myModule", [])
.controller('myController', function($scope)
{
$scope.employees=employees;
$scope.orderBy="name";
});
var employees = [
{
"name": "Julianne Meadows",
"age": 22,
"eyeColor": "brown",
"gender": "female",
"company": "ZOID",
"email": "juliannemeadows@zoid.com",
"phone": "+91 (922) 430-3565",
"salary": 170539
},
{
"name": "Maggie York",
"age": 23,
"eyeColor": "green",
"gender": "female",
"company": "INTRADISK",
"email": "maggieyork@intradisk.com",
"phone": "+91 (882) 504-3554",
"salary": 24686
},
{
"name": "Marquez Wheeler",
"age": 26,
"eyeColor": "green",
"gender": "male",
"company": "PORTALIS",
"email": "marquezwheeler@portalis.com",
"phone": "+91 (957) 521-3390",
"salary": 28090
},
{
"name": "Gayle Bowman",
"age": 29,
"eyeColor": "green",
"gender": "female",
"company": "IMMUNICS",
"email": "gaylebowman@immunics.com",
"phone": "+91 (829) 490-3594",
"salary": 26313
},
{
"name": "Hicks Charles",
"age": 34,
"eyeColor": "green",
"gender": "male",
"company": "HELIXO",
"email": "hickscharles@helixo.com",
"phone": "+91 (852) 558-3308",
"salary": 18556
},
{
"name": "Sasha Zimmerman",
"age": 23,
"eyeColor": "blue",
"gender": "female",
"company": "ZIZZLE",
"email": "sashazimmerman@zizzle.com",
"phone": "+91 (965) 513-3807",
"salary": 20159
},
{
"name": "Roxanne Gilbert",
"age": 40,
"eyeColor": "brown",
"gender": "female",
"company": "BUZZWORKS",
"email": "roxannegilbert@buzzworks.com",
"phone": "+91 (971) 440-2940",
"salary": 217900
}
];
view raw sj.js hosted with ❤ by GitHub

Comments

Popular posts from this blog

Talky Messenger Documentation & Setup

( Github ) Just created a chat app that runs in Node and Socket. the attempt was worthy. Talky is a messenger app built with Node, Express, Socket, Angular & Bootstrap. It's like a server-client structure. (But obviously not like the one we done at OS lab using shared memory). It has a broadcasting structure. Talky does not keep a log on chat. i.e., It doesn't have a memory or database. When we close the browser window, chat history is lost. There I also added a basic console, protected by a password, to send real-time notifications to active clients. The name 'Talky' was suggested by a friend of mine. (hey, thank you for that. The fact is that I am not really good at naming...😝) What if sometimes your college blocks WhatsApp? Try Talky. ( There is also a website on internet in the name of 'Talky' which has no connection with this one. ) Download Talky Messenger To use Talky, all you need is 3 things: Node server Source code...

The Language Evaluation Criteria

There are a vast amount of programming language that we are using. Some are designed to accomplish some specific task. Some are for common uses. Any way the below described is a short ‘summery’ of the criteria we followed to evaluate the language. Overview 1.        Readability a.        Overall Simplicity b.       Orthogonality c.        Data Types d.       Syntax Design 2.        Writability a.        Simplicity and Orthogonality b.       Support for Abstraction c.        Expressivity 3.        Reliability a.        Type Checking b.       Exception Handling c.        Aliasing d.       Readability ...