angular-typeahead
angular-typeahead copied to clipboard
typeahead:selected event when using multiple instances of this directive
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.
+1
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?