I am currently utilizing an AngularStrap typeahead feature and I am in need of a callback function that will be executed when a user selects an item. As per the guidelines provided in the documentation, there is an option called onSelect
which requires a function
to be passed, with the statement:
If specified, this function will be triggered upon selection of an item.
...and...
Options can be set using data attributes on the directive or as an object hash for configuring the service. When using data attributes, add the option name after data-, for example, data-animation=""
Therefore, I attempted to implement it in the following manner:
<input type="text"
class="form-control"
ng-model="selection"
bs-options="item for item in items"
bs-typeahead
data-on-select="onSelect">
I also included the onSelect()
method within my controller:
$scope.onSelect = function() {
console.log('this never gets called :(');
};
Despite this setup, the callback function does not seem to trigger. Is there something I am overlooking?
[edit] dfsq mentioned that it should actually be bs-on-select
according to the library's sources. I have tested this alternative, however, the event only fires once. I have created this Plunker to demonstrate my problem; ideally, the "Number of selection events" should increment with each selection, but it remains at 1.