Consider the following in the body of my html
file:
<html>
...
<body>
...
<div class='container-fluid' ng-controller="TypeaheadCtrl">
<input type="text" ng-model="selected" typeahead="name as entry.name for entry in entries | filter:{name: $viewValue} | limitTo:8"
typeahead-on-select='onSelect($item, $model, $label)'
class="form-control">
{{selection_made}}
</div>
<body>
</html>
where entries
are populated somewhere else. And then this in the controller:
angular.module('ui.bootstrap.demo').controller('TypeaheadCtrl', function($scope, $http) {
...
$scope.onSelect = function ($item, $model, $label) {
$scope.$selection_made = $item;
};
...
});
I have the autocomplete working, but the selection callback doesn't seem to work well.
I was expecting {{selection_made}}
to display whatever is selected, but instead the literal text {{selection_made}}
gets rendered. Why? What am I missing?
Note: I used this answer for reference.