-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
33 lines (28 loc) · 991 Bytes
/
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
(function() {
'use strict';
angular.module('LunchCheck', [])
.controller('LunchCheckController', LunchCheckController);
LunchCheckController.$inject = ['$scope'];
function LunchCheckController($scope) {
$scope.dishes = '';
$scope.message = '';
$scope.checked = false;
$scope.checkLunch = function() {
if ($scope.dishes.trim().length === 0) {
$scope.empty = true;
} else {
$scope.checked = true;
$scope.empty = false;
var arrayDishes = $scope.dishes.split(',');
var arrayDishesWithoutEmptys = arrayDishes.filter(function(v) {
return v.trim() !== '';
});
if (arrayDishesWithoutEmptys.length <= 3) {
$scope.message = 'Enjoy!';
} else {
$scope.message = 'Too much!';
}
}
};
}
})();