Sudarshan Kalebere
Sudarshan Kalebere

Reputation: 3937

Angular strict spell search

How can I search names starting from first letter that user types, I want to know if user types B then names starting from B must be displayed rather than "SBI" word where B comes in second position. I want to search specific words which has first word match.

for example: if 

list ={SBI, BSI, isb, bsisib, be happy, dont worry, hello}

Then If i type h character then I want all the words starting from 'h'. but when i tried it shows 'be happy' 'hello' result for h. I want hello only. Thank you

Upvotes: 1

Views: 517

Answers (2)

Jaanus
Jaanus

Reputation: 16541

If you are using this on input field, then I suggest you to use an existing autocomplete solution for angularjs. There are many of them out there and are quite easy to use.

  1. http://ngmodules.org/modules/ngAutocomplete

    Plunkr:http://plnkr.co/edit/il2J8qOI2Dr7Ik1KHRm8?p=preview

  2. http://angular-ui.github.io/bootstrap/

    Check the typeahead from angular ui bootstrap.

Or just google angularjs autocomplete, you will find tons of results.

Upvotes: 1

Ara Hacobian
Ara Hacobian

Reputation: 121

If you're list isn't extremely long try applying a regular expression on each item in ng-repeat filter.

Not sure if you want first word or first character in each word. Try the following plunker.

Upvotes: 1

Related Questions