ClassAddController.js
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
angular.module('flashy.ClassAddController', ['ui.router', 'ngMaterial']).
controller('ClassAddController', ['$scope', '$state', '$http', function($scope, $state, $http) {
$scope.trySearch = function(searchText) {
return $http.get('/api/sections/search/', {
params: {
q: searchText
}
}).then(function(response) {
return response.data;
});
};
$scope.searchText = '';
$scope.submit = function() {
$http.post('/api/sections/' + $scope.selectedItem.id + '/enroll/').
success(function(data) {
$scope.sections.push($scope.selectedItem);
$state.go('feed', {sectionId: $scope.selectedItem.id});
}).
error(function(data, status, header, config) {
console.log(data);
});
};
/*$scope.trySearch = function() {
$http.get('/api/sections/search', [$scope.searchText]).
success(function(data) {
return data;
}).
error(function(err) {
console.log('you eejit');
});
};*/
}]);