-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
60 lines (45 loc) · 1.35 KB
/
app.js
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
/**
* Created by sandrobirke on 09.12.16.
*/
(function(){
var potatoApp = angular.module('potatoApp', []);
potatoApp.controller('potatoCtrl', function($scope, $http){
var jsonPath = 'data.json';
$http.get(jsonPath).then(function(response){
$scope.potatoData = response.data;
// Kochtypen als Object
$scope.typesArr = [];
for(var i = 0; i < $scope.potatoData.length; i++){
for(var k = 0; k < $scope.potatoData[i].typ.length; k++){
$scope.typesArr.push($scope.potatoData[i].typ[k]);
}
}
$scope.uniqueTypes = $scope.typesArr.filter(function(item, index){
return $scope.typesArr.indexOf(item) == index;
});
// Erntezeit als Object
$scope.pickingArr = [];
for(var i = 0; i < $scope.potatoData.length; i++){
for(var k = 0; k < $scope.potatoData[i].ernte.length; k++){
$scope.pickingArr.push($scope.potatoData[i].ernte[k]);
}
}
$scope.uniquePicking = $scope.pickingArr.filter(function(item, index){
return $scope.pickingArr.indexOf(item) == index;
});
// Filter
$scope.customFilter = function(item){
if(item === null){
return "";
} else {
return item;
}
}
});
});
potatoApp.filter('arrayToList', function(){
return function(arr) {
return arr.join(',');
}
});
})();