-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
67 lines (57 loc) · 1.57 KB
/
script.js
File metadata and controls
67 lines (57 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
var departure = [];
var arrival = [];
for(i =0; i<FLIGHT_DATA.length;i++){
if(FLIGHT_DATA[i].type == "departure") departure.push(FLIGHT_DATA[i]);
else arrival.push(FLIGHT_DATA[i]);
}
var app = angular.module("flightApp", ["ngRoute"]);
app.filter('startFrom', function(){
return function(input, start){
start = +start;
return input.slice(start);
}
})
app.controller("flightCtrl", function($scope){
$scope.sortType = '';
$scope.getSortType = function(type){
$scope.sortType = type;
}
$scope.type = "DEPARTURE";
$scope.data = departure;
$scope.getArr = function(){
$scope.data = arrival;
$scope.type = "ARRIVAL";
$scope.currentPage = 0;
}
$scope.getDep = function(){
$scope.type = "DEPARTURE";
$scope.data = departure;
$scope.currentPage = 0;
}
//pagination
$scope.currentPage = 0;
$scope.itemsPerPage = 10;
$scope.items = [];
for(var i=0; i<$scope.data.length; i++){
$scope.items.push('Product ' + i);
}
$scope.firstPage = function() {
return $scope.currentPage == 0;
}
$scope.lastPage = function() {
var lastPageNum = Math.ceil($scope.items.length / $scope.itemsPerPage - 1);
return $scope.currentPage == lastPageNum;
}
$scope.numberOfPages = function(){
return Math.ceil($scope.items.length / $scope.itemsPerPage);
}
$scope.startingItem = function() {
return $scope.currentPage * $scope.itemsPerPage;
}
$scope.pageBack = function() {
$scope.currentPage = $scope.currentPage - 1;
}
$scope.pageForward = function() {
$scope.currentPage = $scope.currentPage + 1;
}
});