'use strict';

angular.module('core').controller('HomeController', ['$scope', 'Authentication','$http',
  function ($scope, Authentication, $http) {
    // This provides Authentication context.
    $scope.authentication = Authentication;
    $scope.search = function () {
    	console.log('/api/reviews/search/' + $scope.val)
		$http({
		  method: 'GET',
		  url: '/api/reviews/search/' + $scope.val
		}).then(function successCallback(response) {
			//console.log(response.data)
		    $scope.result = response.data;
		  }, function errorCallback(response) {
		    console.log(errorCallback);
		  });
		// get the score
		$http({
		  method: 'GET',
		  url: '/api/reviews/score/' + $scope.val
		}).then(function successCallback(response) {
			//console.log(response.data)
		    $scope.upvotes = response.data.up;
		    $scope.downvotes = response.data.down;
		  }, function errorCallback(response) {
		    console.log(errorCallback);
		  });
    };
    var init = function (){
    	$scope.val = "www.google.com"
    	$scope.search()
    };
    init();
  }
]);

@@ -266,16 +266,19 @@
 n () %7B%0A 
+ //
    %09cons
@@ -324,16 +324,19 @@
 .val)%0A%09%09
+// 
 $http(%7B%0A
@@ -329,34 +329,37 @@
 %0A%09%09// $http(%7B%0A%09%09
+//
   
+ 
 method: 'GET',%0A%09
@@ -351,32 +351,35 @@
 ethod: 'GET',%0A%09%09
+// 
   url: '/api/rev
@@ -399,32 +399,35 @@
  + $scope.val%0A%09%09
+// 
 %7D).then(function
@@ -449,32 +449,35 @@
 k(response) %7B%0A%09%09
+// 
 %09//console.log(r
@@ -484,32 +484,35 @@
 esponse.data)%0A%09%09
+// 
     $scope.resul
@@ -528,26 +528,29 @@
 nse.data;%0A%09%09
+//
   
+ 
 %7D, function 
@@ -569,32 +569,35 @@
 k(response) %7B%0A%09%09
+// 
     console.log(
@@ -610,24 +610,27 @@
 allback);%0A%09%09
+// 
   %7D);%0A%09%09// g

remove search