Fix search controller reloading when a text parameter is added
This replaces the use of $stateParams with parsing the query string in the given URL instead, using $location. This way the controller doesn't reload when a text parameter is added to the URL, which was causing non-text criteria to be lost upon the addition of a text criterion. Change-Id: If1fbf8ce4a06538c97aa430cf5c8e703ac453db0 Task: 3493
This commit is contained in:
parent
28b4809425
commit
13a889d38d
|
@ -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)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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'
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue