search.js 630 B

123456789101112131415161718192021222324
  1. var myApp = angular.module('myApp');
  2. myApp.controller('SearchController', ['$scope', '$http', '$location', '$routeParams', function($scope, $http, $location, $routeParams){
  3. console.log('SearchController loaded...');
  4. $scope.data = {
  5. searchTerm: "",
  6. countryCheck: false
  7. };
  8. $scope.searchResults = [];
  9. $scope.search = function(){
  10. var extraParams = "&num=30";
  11. extraParams += ($scope.data.countryCheck) ? "&country=de" : "";
  12. $http.get('/crawler/apps/?q='+ $scope.data.searchTerm + extraParams).then(function(response){
  13. console.log(response.data);
  14. $scope.searchResults = response.data.results;
  15. });
  16. }
  17. }]);