Skip to content

Commit 5c902df

Browse files
committed
Final Commit
1 parent 0c4b2fc commit 5c902df

File tree

7 files changed

+51
-0
lines changed

7 files changed

+51
-0
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.

dependency-injection/script/app.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
(function () {
2+
3+
angular.module('LunchCheck', [])
4+
.controller('LunchCheckController', LunchCheckController);
5+
6+
LunchCheckController.$inject = ['$scope'];
7+
8+
function LunchCheckController($scope) {
9+
$scope.name = "";
10+
$scope.messages = "";//for message
11+
$scope.msgClass = "text-success";//for color of o/p msg
12+
$scope.msgBorder = "";//for border of input text box
13+
14+
$scope.check = function() {
15+
16+
var input = $scope.name;
17+
var numberOfTypes = input.split(",");
18+
var numberOfItems = 0;
19+
20+
for (var i = 0; i < numberOfTypes.length; i++) {
21+
if (numberOfTypes[i].trim() !== "") {
22+
numberOfItems ++;
23+
}
24+
}
25+
26+
if(numberOfItems === 0)
27+
{
28+
$scope.messages = "Please enter data first";
29+
$scope.msgClass = "text-danger";
30+
$scope.msgBorder = "messageError";
31+
}
32+
else if(numberOfItems <= 3)
33+
{
34+
$scope.messages = "Enjoy!";
35+
$scope.msgClass = "text-success";
36+
$scope.msgBorder = "messageSuccess";
37+
}
38+
else
39+
{
40+
$scope.messages = "Too much!";
41+
$scope.msgClass = "text-danger";
42+
$scope.msgBorder = "messageError";
43+
}
44+
};
45+
46+
};
47+
48+
49+
50+
51+
})();

0 commit comments

Comments
 (0)