<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js">
</script>
<script type="text/javascript" src="js/script.js"></script>
<link rel="stylesheet" href="css/style.css">
</head>
<body ng-app="myModule" ng-controller="myController"
ng-mousemove="coordinate($event)">
<p style="margin-left: 80%">
Coordinates: {{xCoordinate + ', ' + yCoordinate}} </p>
<h1 style="margin-left:50%">{{theTime}}</h1>
<p ng-click="tableShow()">
Click the table headers to change the sorting order: {{count}} </p>
<div ng-show="showMe1">
<table border="1" width="50%" >
<tr ng-click="count = count + 1">
<th >ID</th>
<th ng-click="orderByMe('name')" >Name</th>
<th ng-click="orderByMe('country')">Country</th>
</tr>
<tr ng-repeat="x in names | orderBy:myOrderBy">
<td width="5%">{{ $index + 1 }}</td>
<td>{{x.name}}</td>
<td>{{x.country}}</td>
</tr>
</table>
</div>
<p ng-click="ChangeCase()">Change UpperCase to LowerCase of visa-versa:</p>
<div ng-show="showMe4">
<ul>
<li ng-repeat="x in names"> {{x.name | myFormat}} </li>
</ul>
</div>
<p ng-click="UrlPage()">The url of this page is:</p>
<div ng-show="showMe2">
<h3>{{myUrl}}</h3>
</div>
<p ng-click="HedderChange()">This header will change after 3 seconds:</p>
<div ng-show="showMe3">
<h1>{{myHeader}}</h1>
</div>
<div>
<p>The hexadecimal value of 255 is: {{hex}}</p>
</div>
<div ng-click="SelectOption()">
Select an Option
<select ng-model="selectedNames">
<option ng-repeat="x in names" value="{{x.name}}">{{x.name}}</option>
</select>
</div>
<h1 ng-show="showMe5">You selected: {{selectedNames}}</h1>
</body>
</html>
var myApp=angular.module("myModule",[]).controller("myController", function($scope, $location, $http, $timeout, $interval, hexafy)
{
var employees=[
{name:"Abhishek", dateOfBirth: new Date("June 9,1992"), gender:"Male", salary:20000},
{name:"Atindra", dateOfBirth: new Date("August 9,1992"), gender:"Male", salary:21000},
{name:"Balakrishna", dateOfBirth: new Date("March 9,1992"), gender:"Male", salary:26000}
];
$scope.employees=employees;
$scope.sortColumn="name";
$scope.reverseSort=false;
$scope.sortData = function(column){
$scope.reverseSort = ($scope.sortColumn==column)? !$scope.reverseSort:false;
$scope.sortColumn = column;
}
$scope.getSortClass = function(column){
if($scope.sortColumn==column){
return $scope.reverseSort ? 'arrow-down' : 'arrow-up';
}
return '';
}
$scope.count = 0;
//Sorting method
$scope.names = [
{name:'Jani',country:'Norway'},
{name:'Carl',country:'Sweden'},
{name:'Margareth',country:'England'},
{name:'Hege',country:'Norway'},
{name:'Joe',country:'Denmark'},
{name:'Gustav',country:'Sweden'},
{name:'Birgit',country:'Denmark'},
{name:'Mary',country:'England'},
{name:'Kai',country:'Norway'}
];
$scope.orderByMe = function(x) {
$scope.myOrderBy = x;
}
//information about the location of the current web page
$scope.myUrl = $location.absUrl();
//request data from the server
$http.get("Example1.html").then(function (response) {
$scope.myWelcome = response.data;
});
//The $timeout Service
$scope.myHeader = "Hello World!";
$timeout(function () {
$scope.myHeader = "How are you today?";
//Create Your Own Service
$scope.hex = hexafy.myFunc(255);
}, 3000);
//The $interval Service
$scope.theTime = "Welcome";
$interval(function () {
$scope.theTime = new Date().toLocaleTimeString();
}, 1000);
//Counting
$scope.count = 0;
//ShowMe or HideMe
$scope.showMe1 = false;
$scope.tableShow = function() {
$scope.showMe1 = !$scope.showMe1;
}
$scope.showMe2 = false;
$scope.UrlPage = function() {
$scope.showMe2 = !$scope.showMe2;
}
$scope.showMe3 = false;
$scope.HedderChange = function() {
$scope.showMe3 = !$scope.showMe3;
}
$scope.showMe4 = false;
$scope.ChangeCase = function() {
$scope.showMe4 = !$scope.showMe4;
}
$scope.showMe5 = true;
$scope.SelectOption = function() {
$scope.showMe5 = !$scope.showMe5;
}
//Coordinates
$scope.coordinate = function(myE) {
$scope.xCoordinate = myE.clientX;
$scope.yCoordinate = myE.clientY;
}
});