Merge "Fix search controller reloading when a text parameter is added"

This commit is contained in:
Jenkins 2017-04-05 19:11:04 +00:00 committed by Gerrit Code Review
commit 9de526ab6a
2 changed files with 5 additions and 4 deletions

View File

@ -18,7 +18,7 @@
* This controller provides initialization logic for the generic search view.
*/
angular.module('sb.search').controller('SearchController',
function ($log, $q, $scope, Criteria, $stateParams) {
function ($log, $q, $scope, Criteria, $location) {
'use strict';
/**
@ -39,9 +39,10 @@ angular.module('sb.search').controller('SearchController',
/**
* If a 'q' exists in the state params, go ahead and add it.
*/
if ($stateParams.hasOwnProperty('q') && !!$stateParams.q) {
var params = $location.search();
if (params.hasOwnProperty('q') && !!params.q) {
$scope.defaultCriteria.push(
Criteria.create('Text', $stateParams.q)
Criteria.create('Text', params.q)
);
}
}

View File

@ -26,7 +26,7 @@ angular.module('sb.search',
// Set our page routes.
$stateProvider
.state('sb.search', {
url: '/search?q',
url: '/search',
templateUrl: 'app/search/template/index.html',
controller: 'SearchController'
});