Giter Site home page Giter Site logo

Comments (8)

JustGoscha avatar JustGoscha commented on July 23, 2024

I can imagine examples where they do want to match also for strings that are in the middle of a word. There's no good example I can think of right now in English, but in German there are many words that are consisting of two words... like "Zeitgeist", and if you search for "Geist" you maybe also want to see "Zeitgeist" as a suggestion.

from allmighty-autocomplete.

j0an avatar j0an commented on July 23, 2024

In spanish is very common. Have you got an idea of what can be the approach to that? I will give a try

j.mobile

On Fri, Jun 13, 2014 at 8:59 AM, Goscha Graf [email protected]
wrote:

I can imagine examples where they do want to match also for strings that are in the middle of a word. There's no good example I can think of right now in English, but in German there are many words that are consisting of two words... like "Zeitgeist", and if you search for "Geist" you maybe also want to see "Zeitgeist" as a suggestion.

Reply to this email directly or view it on GitHub:
#34 (comment)

from allmighty-autocomplete.

davidmh avatar davidmh commented on July 23, 2024

Hi J0an,

Ideally, you should do this from the source of the data, but you can also filter it using the on-type attribute.

You can use a regular expression to filter the source. Maybe with \b, to match only the words staring with the typed value. (example)

from allmighty-autocomplete.

j0an avatar j0an commented on July 23, 2024

hey @davidmh, thanks for the example.

but, i don't know how to apply to the autocomplete filter :(

from allmighty-autocomplete.

davidmh avatar davidmh commented on July 23, 2024

I was suggesting to apply it to the source of the data or to the function invoked by the on-type attribute, not directly into the filter.

Do you have a live version I can check? Maybe I can give a more detailed solution.

from allmighty-autocomplete.

j0an avatar j0an commented on July 23, 2024

yes http://movistar.cuomatest.com/atencion-al-cliente/index2.html#/

j.

On Mon, Jun 23, 2014 at 3:38 PM, Chuck [email protected] wrote:

I was suggesting to apply it to the source of the data or to the function
invoked by the on-type attribute, not directly into the filter.

Do you have a live version I can check? Maybe I can give a more detailed
solution.


Reply to this email directly or view it on GitHub
#34 (comment)
.

from allmighty-autocomplete.

davidmh avatar davidmh commented on July 23, 2024

I rewrote the SearchFormController to make it work like you want, but there are a few things you should consider on your implementation.

I've added some comments, but you can read more about it on a similar issue

.controller("SearchFormController", function($scope, $http, $filter, Suggest) {
    var all_suggestions = [];
    $scope.suggestions = [];
    Suggest.query(
        function(data) {
            // Asking for all the suggestions from the start it's an overkill.
            // For this particular case, we can store all the suggestions on a
            // scoped variable, since they are not needed yet.
            all_suggestions = data.data;
        }
    );
    $scope.doSuggest = function(query){
        // The suggestions should be requested here, passing the typed query to
        // the server.
        // But since we already have requested all possible suggestions, we'll
        // filter the matches here.
        $scope.suggestions = $filter('filter')(all_suggestions, function (value) {
            // We only want the suggestions starting with the typed word
            var exp = new RegExp("\\b" + query, "gi");
            return exp.test(value);
        });
    };
})

from allmighty-autocomplete.

j0an avatar j0an commented on July 23, 2024

i love you @davidmh :)

from allmighty-autocomplete.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.