私は角度の新しいjです。私はcustomerIdを検索する入力テキストボックスを持つ検索ページを持っていますが、URL文字列に基づいて検索できる機能を追加したいと思います。AngularJSのURLにクエリ文字列を追加する方法は?
http://localhost:8080/#/search
しかし、私はまた
は、いくつかのいずれかを言うことができる私は、URLにはcustomerIdに基づいて検索できるように
http://localhost:8080/#/search?ACC34ff
http://localhost:8080/#/search?CustomerIdようなものが必要:
例えば、私のURLはどのようにクエリ文字列を追加できますか?
app.config(['$routeProvider',
function($routeProvider) {
$routeProvider
.when('/home', {
templateUrl: 'partials/home.html',
controller: 'homePageCtrl',
reloadOnSearch: true
}).when('/features', {
templateUrl: 'partials/features.html',
controller: 'featuresCtrl',
reloadOnSearch: false
}).when('/search', {
templateUrl: 'partials/search.html',
controller: 'searchCtrl',
reloadOnSearch: false
}).otherwise({
redirectTo: '/home'
});
}]);
コントローラー:
appControllers.controller('searchCtrl', ['$scope','$route','$filter', '$http', '$location','$window','$timeout',
function($scope, $route, $filter, $http, $location, $window, $timeout) {
$scope.searchCustomerFeatures = function() {
if($scope.customerId != null) {
$http.get('/getCustomerFeatures.do', {params: {'customerId': $scope.customerId}}).success(function (data) {
$scope.featuresJson = angular.toJson(data, true);
});
}
}
}]);
HTML:
<li ng-class="{active: isActive('/search')}" style="margin-left: 100px; text-decoration-color: black; font-size: 20px">
<a href="#search" role="tab" data-toggle="tab">Search</a>
</li >
検索ページ:
おかげ
コントローラー側に何も必要ありませんか?私はそれが顧客IDをどのように使用するかについては明確ではない – user3407267
また、http:// localhost:8080 /#/ search?http:// localhost:8080 /#/検索 – user3407267
私の悪い。パラメータを読み取るようにコントローラを設定する必要があります。 $ http.get( '/ Search /' + $ routeParams.customerId) .success(機能(応答){ .... }); – wduqu001