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'); }); };*/ }]);