Php 如何使用Angular js传递url的搜索关键字,以及如何基于该搜索关键字检索结果

Php 如何使用Angular js传递url的搜索关键字,以及如何基于该搜索关键字检索结果,php,angularjs,angular-material,Php,Angularjs,Angular Material,我想使用angular js显示搜索结果,当我们从自动建议中选择时,搜索关键字将通过url并显示特定的搜索关键字结果。我刚开始使用angular js,有人能帮我吗 js文件 var app = angular.module('myApp', ['ngMaterial']); app.controller('myCtrl', function ($scope, $http, $q, GetCountryService) { $scope.searchText =

我想使用angular js显示搜索结果,当我们从自动建议中选择时,搜索关键字将通过url并显示特定的搜索关键字结果。我刚开始使用angular js,有人能帮我吗

js文件

   var app = angular.module('myApp', ['ngMaterial']);

    app.controller('myCtrl', function ($scope, $http, $q, GetCountryService) {

        $scope.searchText = "";
        $scope.Person = [];
        $scope.selectedItem = [];
        $scope.isDisabled = false;
        $scope.noCache = false;

        $scope.selectedItemChange = function (item) {
            //alert("Item Changed");
        }
        $scope.searchTextChange = function (str) {
            return GetCountryService.getCountry(str);
        }

    });

    app.factory('GetCountryService', function ($http, $q) {
        return {
            getCountry: function(str) {
                // the $http API is based on the deferred/promise APIs exposed by the $q service
                // so it returns a promise for us by default
                var url = "http://www.example/index.php/admin/default/searchcompanies?token="+str;
                return $http.get(url)
                    .then(function(response) {
                        if (typeof response.data.records === 'object') {
                           alert(response.data.records);
                            return response.data.records;
                        } else {
                            // invalid response
                            return $q.reject(response.data.records);
                        }

                    }, function(response) {
                        // something went wrong
                        return $q.reject(response.data.records);
                    });
            }
        };
    });
查看文件

<div ng-controller="myCtrl">
  <div layout="row" layout-xs="column">
    <div flex="85" flex-xs="100" layout="row" layout-align="left center">
      <form name="searchForm" flex ng-controller="myCtrl" layout="row" ng-submit="$event.preventDefault()">
        <div md-no-float class="md-block m-0 md-accent md-subhead" flex="50" flex-xs="70">
          <md-content>
            <md-autocomplete ng-disabled="isDisabled" md-no-cache="noCache" md-selected-item="selectedItem" md-search-text="searchText" md-items="item in searchTextChange(searchText)" md-item-text="item.title" md-min-length="0" placeholder="Select Company?">
              <md-item-template>
                <span md-highlight-text="searchText" md-highlight-flags="^i">{{item.title}}</span>
              </md-item-template>
              <md-not-found>
                No Company matching "{{searchText}}" were found.
              </md-not-found>
            </md-autocomplete>
            <md-button class="md-raised md-accent m-0" style="display:inline-block;" onclick="location.href='/index.php/admin/default/searchresults?={{item.title}}';">
              <md-icon ng-bind="'search'"></md-icon>
            </md-button>
          </md-content>
          <br/>
        </div>
      </form>
    </div>
  </div>
</div>

{{item.title}
未找到与“{searchText}}”匹配的公司。


yoiu想要触发
selectedItemChange
的方法对吗?是的,该关键字传递到了url@julientassinyoi你想要触发
selectedItemChange
的方法对吗?是的,该关键字传递到了url@JulienTASSIN