classMLRemoteSearchController
Source: controllers/
extends MLSearchController
base search controller class; the prototype for an angular search controller. implements MLRemoteInputService, for use with ml-remote-input
Note: this style requires you to use the controllerAs syntax.
(function() {
'use strict';
angular.module('app').controller('SearchCtrl', SearchCtrl);
SearchCtrl.$inject = ['$scope', '$location', 'MLSearchFactory', 'MLRemoteInputService'];
// inherit from MLRemoteSearchController
var superCtrl = MLRemoteSearchController.prototype;
SearchCtrl.prototype = Object.create(superCtrl);
function SearchCtrl($scope, $location, searchFactory, remoteInput) {
var ctrl = this;
var mlSearch = searchFactory.newContext();
MLRemoteSearchController.call(ctrl, $scope, $location, mlSearch, remoteInput);
// override a superCtrl method
ctrl.updateSearchResults = function updateSearchResults(data) {
superCtrl.updateSearchResults.apply(ctrl, arguments);
console.log('updated search results');
}
ctrl.init();
}
})();
Methods
new MLRemoteSearchController($scope, $location, mlSearch, remoteInput)
Parameters
| Name | Type | Optional | Description |
|---|---|---|---|
|
$scope |
Object |
|
child controller's scope |
|
$location |
Object |
|
angular's $location service |
|
mlSearch |
|
child controller's searchContext |
|
|
remoteInput |
|
child controller's remoteInput instance |
Property
| Name | Type | Optional | Description |
|---|---|---|---|
|
remoteInput |
|
child controller's remoteInput instance |
- Extends
- MLSearchController
Methods
_search() → Promise
search implementation function
sets MLSearchController#searchPending to true, invokes MLSearchContext#search with MLSearchController#updateSearchResults as
the callback, and invokes MLSearchController#updateURLParams
- Inherited from
- MLSearchController#_search
- Returns
-
the promise from MLSearchContext#search
clearFacets() → Promise
clear all facet selections, and run a search
- Inherited from
- MLSearchController#clearFacets
- Returns
-
the promise from MLSearchController#_search
init() → Promise
initialize the controller, wiring up the remote input service and invoking MLSearchController#init
- Returns
-
Promisethe promise from MLSearchContext#fromParams
locationChange(e, newUrl, oldUrl) → Promise
handle the $locationChangeSuccess event
checks if mlSearch URL params or additional params have changed (using the child controller's parseExtraURLParams() method, if available), and, if necessary, initiates a search via MLSearchController#_search
Parameters
| Name | Type | Optional | Description |
|---|---|---|---|
|
e |
|
|
the |
|
newUrl |
|
|
|
|
oldUrl |
|
|
- Inherited from
- MLSearchController#locationChange
- Returns
-
the promise from MLSearchContext#locationChange
parseExtraURLParams() → Boolean
UNIMPLEMENTED EXTENSION METHOD
implement to support extra URL params that can trigger a search;
should read extra URL params, and update the controller state
- Inherited from
- MLSearchController#parseExtraURLParams
- Returns
-
should a search be triggered
reset() → Promise
clear qtext, facet selections, boost queries, and additional queries. Then, run a search.
- Inherited from
- MLSearchController#reset
- Returns
-
the promise from MLSearchController#_search
search([qtext]) → Promise
the primary search method, for use with any user-triggered searches (for instance, from an input control)
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
qtext |
|
Yes |
if present, updates the state of MLSearchController#qtext |
- Inherited from
- MLSearchController#search
- Returns
-
the promise from MLSearchController#_search
showMoreFacets(facet, facetName[, step]) → Promise
Appends additional facet values to the provided facet object.
Parameters
| Name | Type | Optional | Description |
|---|---|---|---|
|
facet |
|
|
a facet object from MLSearchController#response |
|
facetName |
|
|
facet name |
|
step |
|
Yes |
the number of additional facet values to retrieve (defaults to |
- Inherited from
- MLSearchController#showMoreFacets
- Returns
-
the promise from MLSearchContext#showMoreFacets
suggest(qtext[, options]) → Promise
Gets search phrase suggestions based on the current state. This method can be passed directly to the ui-bootstrap typeahead directive.
Parameters
| Name | Type | Optional | Description |
|---|---|---|---|
|
qtext |
|
|
the partial-phrase to match |
|
options |
|
Yes |
string options name (to override suggestOptions), or object for adhoc combined query options |
- Inherited from
- MLSearchController#suggest
- Returns
-
the promise from MLSearchContext#suggest
toggleFacet(facetName, value) → Promise
toggle the selection state of the specified facet value
Parameters
| Name | Type | Optional | Description |
|---|---|---|---|
|
facetName |
|
|
the name of the facet to toggle |
|
value |
|
|
the value of the facet to toggle |
- Inherited from
- MLSearchController#toggleFacet
- Returns
-
the promise from MLSearchController#_search
toggleNegatedFacet(facetName, value) → Promise
toggle the selection state of the specified NEGATED facet value
Parameters
| Name | Type | Optional | Description |
|---|---|---|---|
|
facetName |
|
|
the name of the NEGATED facet to toggle |
|
value |
|
|
the value of the NEGATED facet to toggle |
- Inherited from
- MLSearchController#toggleNegatedFacet
- Returns
-
the promise from MLSearchController#_search
updateExtraURLParams()
UNIMPLEMENTED EXTENSION METHOD
implement to support additional URL params that can trigger a search;
should update extra URL params from the controller state
- Inherited from
- MLSearchController#updateExtraURLParams
updateSearchResults(data) → MLSearchController
update controller state by invoking MLSearchController#updateSearchResults, then pass the latest qtext to the remote input service
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
data |
Object |
|
the response from MLSearchContext#search |
- Returns
-
MLSearchControllerthis
updateURLParams() → MLSearchController
updates URL params based on the current MLSearchContext state, preserving any additional params. invokes the child controller's updateExtraURLParams() method, if available
- Inherited from
- MLSearchController#updateURLParams
- Returns
-
this