我正在使用Angular UI-Bootstrap中的typeahead,并希望将其用作选择多个选项的方式,因此当selectMatch方法启动时,我需要获取所选值,但我在控制器中找不到如何实现它的方法。
<div class='container-fluid' ng-controller="TypeaheadCtrl">
<pre>Model: {{selected| json}}</pre>
<input type="text" ng-model="selected" typeahead="state for state in states | filter:$viewValue">
如果我观察所选的值,每当按键被按下时我都会得到变化...
scope.$watch('selected', function(newValue, oldValue) {... });
我知道当用户按下回车键或点击列表时,会调用selectMatch方法,但我不知道如何在那个方法上设置回调...
谢谢!
state.id as state.name for state in states
,那么解释起来会更容易。在这种情况下,$item
是state
,$model
是state.id
,$label
是state.name
。 - Aximili