Skip to content

Commit 2e80b2e

Browse files
author
Jon Myrick
authored
Merge pull request CodewarsClone#42 from CodewarsClone/wedBranch3
Wed branch3
2 parents 24c1c9a + 4500314 commit 2e80b2e

5 files changed

Lines changed: 17 additions & 10 deletions

File tree

controllers/kataCtrl.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,22 @@ module.exports = {
1818
console.log(err);
1919
res.status(500).json(err);
2020
}
21-
return res.status(200).json(kata);
21+
return res.status(200).json(kata[0]);
2222
})
2323
}
2424
},
2525

2626
getRandomKata: (req, res, next) => {
27-
console.log(1);
2827
if (!req.params.kyu) {
29-
console.log(2);
3028
db.read.katas((err, katas) => {
31-
console.log(3);
3229
if (err) {
3330
console.log(err);
3431
res.status(500).json(err);
3532
}
36-
console.log(4);
3733
return res.status(200).json(katas[Math.floor(Math.random() * katas.length + 1)]);
3834
})
3935
} else {
40-
console.log(2.1);
4136
db.read.random_by_kyu([req.params.kyu], (err, katas) => {
42-
console.log(3.1);
4337
if (err) {
4438
console.log(err);
4539
res.status(500).json(err);

src/components/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ $stateProvider
3737
.state('menu.solutions',{
3838
url: 'solutions',
3939
templateUrl:'./components/solutions/solutions.html',
40-
// controller: 'solutionsCtrl'
40+
controller: 'solutionsCtrl'
4141
})
4242
.state('menu.training',{
4343
url: 'training',

src/components/mainService.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ this.user = {}
5757
this.getKataById = (kataid) => {
5858
return $http({
5959
method: 'GET',
60-
url: `http://192.168.0.186:3030/api/kata/` + kataid
60+
url: `/api/kata/` + kataid
6161
});
6262
};
6363

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<div ng-init="init()"></div>

src/components/solutions/solutionsCtrl.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33

44
angular.module('app').controller('solutionsCtrl', function($scope, $state, mainService) {
55

6-
// get all solutions for one kata (by kataid) using the kataSolutions function on service.
6+
// get all solutions for one kata (by kataid) using the getKataSolutions function on service.
7+
$scope.getKataSolutions = (kataid) => {
8+
mainService.getKataSolutions(kataid).then(response => {
9+
$scope.kataSolutions = response.data;
10+
console.log($scope.kataSolutions)
11+
})
12+
}
13+
14+
$scope.init = () => {
15+
$scope.getKataSolutions(1 /* replace 1 with kataid when set up */);
16+
}
17+
18+
719

820
});

0 commit comments

Comments
 (0)