mbenford / ngTagsInput

Tags input directive for AngularJS
http://mbenford.github.io/ngTagsInput
MIT License
1.64k stars 541 forks source link

Autocomplete list items not showing selected (Angular 1.3 only) #822

Open numscrl opened 7 years ago

numscrl commented 7 years ago

Selected list item in the autocomplete list does not appear selected when running in an Angular 1.3.11 environment. Selected autocomplete list items appear normal in Angular 1.4+

behamon commented 6 years ago

I have the same issue. Unfortunately I can't upgrade right now. Anyone found a solution to this?

numscrl commented 6 years ago

I ended up modifying the library code to resolve the problem, as follows:

scope.getSuggestionClass = function (item, index)
{
   var selected = item === suggestionList.selected;
   var classes = [scope.matchClass({ $match: item, $index: index, $selected: selected }), { selected: selected }];

   // REVISED TO MERGE OUTPUT ARRAY INTO SINGLE OBJECT AS ARRAY FORMAT DOES NOT SEEM
   // TO BE SUPPORTED FOR NG-CLASS DIRECTIVE IN ANGULAR 1.3

   var output = {};

   angular.forEach( classes, function( ngClass )
   {
       angular.forEach( ngClass, function( value, key )
       {
           output[key] = value;
       });
   });

   // END REVISION

   return output;
};