Searches items for supplied search terms.


Basic usage


Class members


NameTypeDefault valueDescription
displayWithFunction | nullnullFunction that maps an option's value to its display value in the trigger.
maxResultsnumber20Maximum number of results to show in the search.
searchTermstring""Search term to use when executing the search. Updating this value will run a new search and update the results.
skipResultsnumber0Number of results to skip from the results pagination.
classListvoidCSS class for display.


errorEventEmitter<any>Emitted when an error occurs.
resultLoadedEventEmitter<NodePaging>Emitted when search results have fully loaded.


Customise Search Results

You can add a custom template to show the search results when once they are loaded:

<adf-search [searchTerm]="searchTerm">
    <ng-template let-result>
            <li *ngFor="let item of result?.list?.entries">
                {{ item? }}

The results are provided via the $implicit variable of angular2 and can be accessed via the sugar syntax 'let-yourChosenName'. The example above will give results like the following:


However, you can use a more complex template if necessary:

<adf-search class="adf-search-result-autocomplete"
    <ng-template let-data>
        <mat-list *ngIf="isSearchBarActive()" id="autocomplete-search-result-list">
                *ngFor="let item of data?.list?.entries; let idx = index"
                <mat-icon mat-list-icon>
                    <img [src]="getMimeTypeIcon(item)" />
                    <h4 mat-line id="result_name_{{idx}}"
                        *ngIf="highlight; else elseBlock"
                        [innerHtml]=" | highlight: searchTerm">
                        {{ item? }}</h4>
                    <ng-template #elseBlock>
                        <h4 class="adf-search-fixed-text" mat-line id="result_name_{{idx}}" [innerHtml]=""></h4>
                    <p mat-line class="adf-search-fixed-text"> {{item?.entry.createdByUser.displayName}} </p>
                *ngIf="data?.list?.entries.length === 0">
                <p mat-line class="adf-search-fixed-text">{{ 'SEARCH.RESULTS.NONE' | translate:{searchTerm: searchTerm} }}</p>


Attach an input field to the search

You can also attach an input field to the search component via the searchAutocomplete property. Export the search panel instance into a local template variable and bind that variable to the input's searchAutocomplete property. The example below demonstrates this with an instance called "search":

<input type="text" [searchAutocomplete]="search">

<adf-search #search="searchAutocomplete">
    <ng-template let-result>
        <span *ngFor="let item of result?.list?.entries">
            {{ item? }}

By doing this, you can get the results as the user types into the input text.

Custom search configuration

You can get finer control over the parameters of a search by defining them in a custom QueryBody object. The recommended way to do this is with a custom implementation of the Search Configuration interface. The ADF source provides a standard implementation of this interface, SearchConfigurationService that you can use as a base to adapt to your needs. See the Search Configuration interface page for full details of how to customize your search.

See Also

© 2023 Alfresco Software, Inc. All Rights Reserved.