bootstrap icon indicating copy to clipboard operation
bootstrap copied to clipboard

Typeahead Enhancement: messaging for when there are no matches

Open joshuacc opened this issue 12 years ago • 12 comments

It would be nice if there was a way to specify a message to display when there are no matches. For example: "There are no cities matching 'Metropolis'. Please check for spelling errors."

joshuacc avatar Apr 02 '14 13:04 joshuacc

@joshuacc This sounds like a good addition.

bekos avatar Apr 09 '14 17:04 bekos

@bekos I need this for a project at work, so I'll try to put together a pull request.

joshuacc avatar Apr 09 '14 18:04 joshuacc

:+1:

bekos avatar Apr 09 '14 18:04 bekos

Need this functionality as well. Is there any workaround for it?

opetriienko avatar Jul 31 '14 11:07 opetriienko

@wrestlero when there is no result, I return an array with one item with a custom property "isNoResult" set to true. Then in the custom template I check that property to show the correct html.

Controller:

var getNoResult = function (searchTerm) {
        return [{
            isLast: false,
            isNoResult: true,
            isGrouped: false,
            Title: $translate.instant('NoVideoResultsFound') + ' "' + searchTerm + '"'
        }];
    };

//after calling server for results:
.then(function (data) {
            if (data === null)
                return getNoResult(searchTerm);

Custom template:

<!-- Normal item -->
<a class="search-dropdown-item clearfix" ng-if="!match.model.isLast && !match.model.isGrouped && !match.model.isNoResult" ng-href="{{match.model.url}}">
    <span class="search-dropdown-item-image pull-left">
        <img ng-src="{{match.model.Image}}" />
    </span>
    <div>
        <p class="title">{{match.model.Title}}</p>
        <p class="description">{{match.model.ShortDescription | characters:100}}</p>
        <age-rating age="match.model.Age" template-url="components/age/search-tv-rating.html"></age-rating>
    </div>
</a>

<!-- Grouped item -->
<div class="grouped-search" ng-if="match.model.isGrouped">
    <strong>{{match.model.Title}}</strong>
    <ul class="list-unstyled">
        <li ng-repeat="item in match.model.items">
            <a ng-href="{{item.url}}">{{item.Title}}</a>
        </li>
    </ul>
</div>

<!-- Last item -->
<div class="search-last-item" ng-if="match.model.isLast">{{match.model.Title}}</div>

<!-- No result item -->
<div class="search-no-results" ng-if="match.model.isNoResult">{{match.model.Title}}</div>

You can see that my typeahead has several others functionalities using this trick. (isGrouped, isLast).

JobaDiniz avatar Aug 20 '14 20:08 JobaDiniz

+1: It would be really useful to have the possibility of displaying a message when there are not results to the search.

lynchblue avatar Sep 02 '14 09:09 lynchblue

+1

arjunasuresh3 avatar Jun 01 '15 14:06 arjunasuresh3

+1

vicch avatar Jul 05 '15 03:07 vicch

+1

jodytate avatar Jul 08 '15 18:07 jodytate

+1

rasmi avatar Jul 15 '15 19:07 rasmi

See #2792.

jczerwinski avatar Aug 01 '15 18:08 jczerwinski

The functionality will look like this:

<input typeahead-no-results="noResults">
<span ng-if="noResults">No Results found</span>

jczerwinski avatar Aug 01 '15 18:08 jczerwinski