0

I am trying to do a autocomplete with typeahead that match exact characters like t will match but not T. But I cannot get it to work as I want.

Have tried to find a solution in google and stackoverflow like: AngularJs UI typeahead match on leading characters AngularJS Filter Exact Match

This is how my example code looks like: http://plnkr.co/edit/mXthLrqNqpCyRYmj2qmT?p=preview

Thanks for helping.

Best Regards, Johnny

Community
  • 1
  • 1
Johnny Ha
  • 633
  • 5
  • 21

1 Answers1

4

Are you looking for this SEE HERE

actually you were comparing by lower case hence it fetched you result in case of 't' and 'T' both

 $scope.startsWith = function(state, viewValue) {
          return state.substr(0, viewValue.length) == viewValue;
        }

fetching records for T but not for t

Vinod Louis
  • 4,812
  • 1
  • 25
  • 46
  • I yes I am looking for something like that, but in that example they are using a simple array. I have a array of objects. – Johnny Ha Nov 01 '13 at 13:01
  • can you now see my plunker once more i have update it – Vinod Louis Nov 01 '13 at 13:07
  • Thanks for helping me, I think that I found what was wrong with my code. I have tried this before I ask for help "return state.substr(0, viewValue.length) == viewValue;" with filter|$viewValue:startsWith. In my solution I am using angularjs version 1.0.7 with bootstrap 0.6.0. It seems that they don't play with each other so well. When I changed to angularjs version 1.1.5, everything works fine then. You can test your plunk with a stable release like 1.0.8 and you will see what's happen. – Johnny Ha Nov 01 '13 at 13:30