Commit 6f48f3a680848ace15ab3560fa31f705206b7013
1 parent
da678ed382
Exists in
master
and in
1 other branch
unbreak class add
Showing 1 changed file with 3 additions and 6 deletions Inline Diff
scripts/ClassAddController.js
View file @
6f48f3a
angular.module('flashy.ClassAddController', ['ui.router', 'ngMaterial']). | 1 | 1 | angular.module('flashy.ClassAddController', ['ui.router', 'ngMaterial']). | |
2 | 2 | controller('ClassAddController', function($scope, $state, $http, UserService) { | ||
controller('ClassAddController', ['$scope', '$state', '$http', function($scope, $state, $http) { | 3 | |||
4 | ||||
5 | ||||
$scope.trySearch = function(searchText) { | 6 | 3 | $scope.trySearch = function(searchText) { | |
return $http.get('/api/sections/search/', { | 7 | 4 | return $http.get('/api/sections/search/', { | |
params: { | 8 | 5 | params: { | |
q: searchText | 9 | 6 | q: searchText | |
} | 10 | 7 | } | |
}).then(function(response) { | 11 | 8 | }).then(function(response) { | |
return response.data; | 12 | 9 | return response.data; | |
}); | 13 | 10 | }); | |
}; | 14 | 11 | }; | |
15 | 12 | |||
$scope.searchText = ''; | 16 | 13 | $scope.searchText = ''; | |
$scope.submit = function() { | 17 | 14 | $scope.submit = function() { | |
$http.post('/api/sections/' + $scope.selectedItem.id + '/enroll/'). | 18 | 15 | $http.post('/api/sections/' + $scope.selectedItem.id + '/enroll/'). | |
success(function(data) { | 19 | 16 | success(function(data) { | |
$scope.sections.push($scope.selectedItem); | 20 | 17 | UserService.getUserData().sections.push($scope.selectedItem); | |
$state.go('feed', {sectionId: $scope.selectedItem.id}); | 21 | 18 | $state.go('feed', {sectionId: $scope.selectedItem.id}); | |
}). | 22 | 19 | }). | |
error(function(data, status, header, config) { | 23 | 20 | error(function(data, status, header, config) { | |
// shhhh | 24 | 21 | // shhhh | |
$state.go('feed', {sectionId: $scope.selectedItem.id}); | 25 | 22 | $state.go('feed', {sectionId: $scope.selectedItem.id}); | |
}); | 26 | 23 | }); | |
}; | 27 | 24 | }; | |
28 | 25 | |||
/*$scope.trySearch = function() { | 29 | 26 | /*$scope.trySearch = function() { | |
$http.get('/api/sections/search', [$scope.searchText]). | 30 | 27 | $http.get('/api/sections/search', [$scope.searchText]). | |
success(function(data) { | 31 | 28 | success(function(data) { | |
return data; | 32 | 29 | return data; | |
}). | 33 | 30 | }). | |
error(function(err) { | 34 | 31 | error(function(err) { | |
console.log('you eejit'); | 35 | 32 | console.log('you eejit'); | |
}); | 36 | 33 | }); |