Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typeahead:selected event when using multiple instances of this directive #68

Open
rahilsondhi opened this issue May 20, 2015 · 2 comments

Comments

@rahilsondhi
Copy link

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.

@aleksey6689
Copy link

+1

@hmil
Copy link
Collaborator

hmil commented Oct 14, 2016

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants