forked from CodewarsClone/Codewars
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhomeCtrl.js
More file actions
39 lines (29 loc) · 1.2 KB
/
Copy pathhomeCtrl.js
File metadata and controls
39 lines (29 loc) · 1.2 KB
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
/***********HOME CONTROLLER***********/
angular.module('app').controller('homeCtrl', function($scope, $state, mainService) {
$scope.languageOptions = ["JavaScript", "Ruby", "C++"];
$scope.progressOptions = ["Fundamentals", "Rank Up", "Practice and Repeat", "Beta", "Random"];
$scope.getUser = () => {
mainService.getUser().then(response => {
console.log(response.data);
mainService.user = response.data;
mainService.user.kyu_level = mainService.rankCalculator(mainService.user);
$scope.getRandomKata();
})
}
$scope.getRandomKata = () => {
mainService.getRandomKata(mainService.user.kyu_level).then(response => {
console.log(response.data);
$scope.randomKata = response.data;
})
}
$scope.getUserKatas = (userid) => {
mainService.getUserKatas(userid).then(response => {
$scope.userKatas = response.data;
console.log($scope.userKatas);
})
}
// the random kata is stored on $scope.randomKata.
// If there is a button you can link the button to $scope.getRandomKata
$scope.getUser();
$scope.getUserKatas(mainService.user.id);
});