title: How to link Laravel controller function with Angular View
body: <p>I am working on a laravel web application , recently i embedded angularjs for searching data from database. But for now i just used an array to search.In my AngularJs Module i point to search function as <code>$scope.url = 'Students@search';</code> but this is not working for me. <strong>I want to know that how to tell AngularJS <code>$scope.url</code> to point to this search function in my Controller so that user can search data easily.</strong>
  I have search function in Students Controller:</p>
  
  <pre><code> public function search(){
              $data = file_get_contents("php://input");
  
              $objData = json_decode($data);
  
              // Static array for this demo
              $values = array('php', 'web', 'angularjs', 'js');
  
              // Check if the keywords are in our array
              if(in_array($objData-&gt;data, $values)) {
                  echo 'I have found what you\'re looking for!';
              }
              else {
                  echo 'Sorry, no match!';
              }
    }
  </code></pre>
  
  <p><strong>MyApp.js File :</strong></p>
  
  <pre><code>function SearchCtrl($scope, $http) {
      $scope.url = 'Students@search'; // The url of our search
  
      // The function that will be executed on button click (ng-click="search()")
      $scope.search = function() {
  
          // Create the http post request
          // the data holds the keywords
          // The request is a JSON request.
          $http.post($scope.url, { "data" : $scope.keywords}).
          success(function(data, status) {
              $scope.status = status;
              $scope.data = data;
              $scope.result = data; // Show result from server in our &lt;pre&gt;&lt;/pre&gt; element
          })
          .
          error(function(data, status) {
              $scope.data = data || "Request failed";
              $scope.status = status;         
          });
      };
  }
  </code></pre>
  
  <p><strong>Angular Search View:</strong></p>
  
  <pre><code>&lt;div ng-controller="SearchCtrl"&gt;
                                      &lt;form class="well form-search"&gt;
                                          &lt;label&gt;Search:&lt;/label&gt;
                                          &lt;input type="text" ng-model="keywords" class="input-medium search-query" placeholder="Keywords..."&gt;
                                          &lt;button type="submit" class="btn" ng-click="search()"&gt;Search&lt;/button&gt;
                                          &lt;p class="help-block"&gt;Try for example: "php" or "angularjs" or "asdfg"&lt;/p&gt;      
                                      &lt;/form&gt;
                                      &lt;pre ng-model="result"&gt;
                                      @{{result}}
                                      &lt;/pre&gt;
  &lt;/div&gt;
  </code></pre>