-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
49 lines (43 loc) · 1.86 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
angular.module('multiSelectMenu',['ui.bootstrap'])
.controller('multiSelectController',['$scope', '$timeout', function($scope, $timeout){
$scope.selectMenuLable = "Select your skill sets";
$scope.filterOptions = [
{description:'HTML5', name:'HTML5', order:1},
{description:'CSS3', name:'CSS3', order:2},
{description:'JavaScript', name:'JavaScript', order:3},
{description:'jQuery', name:'jQuery', order:4},
{description:'Bootstrap', name:'Bootstrap', order:5},
{description:'Angularjs', name:'Angularjs', order:6},
{description:'Angular2', name:'Angular2', order:7},
{description:'TypeScript', name:'TypeScript', order:8},
{description:'Nodejs', name:'Nodejs', order:9}
];
$scope.selectedTechnologies = [];
// whenever user check the option this function will get called
// it will check if the option is in selectedFilter option or not
$scope.toggleFilterOption = function(value) {
console.log(value)
var index = $scope.selectedTechnologies.indexOf(value.name);
console.log(index)
if(index !== -1) {
$scope.selectedTechnologies.splice(index, 1);
console.log( $scope.selectedTechnologies)
}
else{
$scope.selectedTechnologies.push(value.name);
}
// update the dropdown text to reflect the items selected
updateFilterOptionsLabel();
};
var updateFilterOptionsLabel = function(){
if ($scope.selectedTechnologies.length===1 ){
$scope.selectMenuLable = $scope.selectedTechnologies[0];
}
else if ($scope.selectedTechnologies.length>1){
$scope.selectMenuLable = $scope.selectedTechnologies.length + " Skills are selected";
}
else {
$scope.selectMenuLable = "Select your skilles";
}
}
}])