-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
75 lines (65 loc) · 2 KB
/
demo.html
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
68
69
70
71
72
73
74
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>angular-enum-flag-directive example</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap-theme.min.css">
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/angularjs/1.2.27/angular.min.js'></script>
</head>
<body>
<div ng-app="MyApp" class="container">
<div ng-controller="MyController">
<h1>angular-enum-flag-directive example</h1>
<h2>Example options</h2>
<div class="checkbox">
<label>
<input type="checkbox" ng-enum-flag="ColorEnum.RED" ng-enum-model="selectedColors" /> RED
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" ng-enum-flag="ColorEnum.GREEN" ng-enum-model="selectedColors" /> GREEN
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" ng-enum-flag="ColorEnum.BLUE" ng-enum-model="selectedColors" /> BLUE
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" ng-enum-flag="ColorEnum.YELLOW" ng-enum-model="selectedColors" /> YELLOW
</label>
</div>
<h2>Output</h2>
<div>Value of selectedColors: {{ selectedColors }}</div>
</div>
</div>
<script src="angular-enum-flag-directive-min.js"></script>
<script type='text/javascript'>
// App
var myApp = angular.module('MyApp', ['enumFlag']);
// ColorEnum Factory
angular.module('MyApp').factory('ColorEnum', [
function () {
return Object.freeze({
RED: 1,
GREEN: 2,
BLUE: 4,
YELLOW: 8
});
}
]);
// Controller
angular.module('MyApp').controller('MyController', ['$scope','ColorEnum',
function ($scope, ColorEnum) {
$scope.ColorEnum = ColorEnum;
$scope.selectedColors = 7; // Default of RED, GREEN and BLUE
}
]);
</script>
</body>
</html>