angular-typeahead icon indicating copy to clipboard operation
angular-typeahead copied to clipboard

typeahead:selected event when using multiple instances of this directive

Open rahilsondhi opened this issue 9 years ago • 2 comments

If I'm using this directive in multiple places on the page, how do I bind to the typeahead:selected event of a specific directive?

Right now in my controller I have $scope.$on 'typeahead:selected', (e, suggestion, dataset) ->, but that is not specific if I'm using many instances of this directive on the same page.

rahilsondhi avatar May 20 '15 05:05 rahilsondhi

+1

aleksey6689 avatar Sep 29 '16 11:09 aleksey6689

That is problematic indeed. A solution would be to use the name attribute.

We could then do:

  $scope.$on('typeahead:select', function(evt) {
    console.log('clicked on ' + evt.targetScope.name);
  });

But that requires to add name: '@' in the directive definition. See this plunkr: http://plnkr.co/edit/a4vusFyXcGHVTWvoPPXY?p=preview

Would that solve your problem?

hmil avatar Oct 14 '16 06:10 hmil