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
| var app = angular.module('DisplayRequest', ['ngCookies', 'ngSanitize']);
app.controller('ControllerDisplayRequest', function($scope, $http, $window, $cookies){
var ApiKey = $cookies.get('api_key');
$scope.Error1 = false;
$scope.Error2 = false;
$scope.setSkill = function (skill) {
$scope.chosenSkill = skill;
console.log($scope.chosenSkill);
};
$http(
{method: 'GET',
url: 'http://umannity.com:1337/user',
headers: {'Authorization': ApiKey }
}).success(function (data){
$scope.skills = data.skills;
var parsedSkills = JSON.parse("[\"informatique\",\"enseignement\"]"); //JSON.parse("[\"informatique\",\"enseignement\"]");
var i = 0;
$scope.TitleCategories = "";
while (parsedSkills.length != i) {
$scope.TitleCategories += "<li> <a ng-click='setSkill(\""+ parsedSkills[i] +"\")' class='n b margin' href='#bySkill' data-toggle='tab'> "+ parsedSkills[i] +"</a> </li>";
i++;
}
//document.getElementById("TitleTabs").innerHTML += TitleCategories;
$http(
{method: 'GET',
url: 'http://umannity.com:1337/request',
headers: {'Authorization': ApiKey }
}).success(function (data){
$scope.allhelpdata = data;
}).error(function (response){
$scope.Error1 = true;
console.log("error");
});
$http(
{method: 'GET',
url: 'http://umannity.com:1337/request',
headers: {'Authorization': ApiKey },
data :{
"skills": $scope.skills
}
}).success(function (data){
$scope.skillshelpdata = data;
}).error(function (response){
$scope.Error2 = true;
console.log("error");
});
}).error(function (data){
console.log("Fail get skills");
});
$scope.search = function (item) {
if ($scope.searchText == undefined)
return true;
else {
if (item.name.toLowerCase().indexOf($scope.searchText.toLowerCase()) != -1 ||
item.skills.toLowerCase().indexOf($scope.searchText.toLowerCase()) != -1)
return true;
}
return false;
}
}); |
Partager