【发布时间】:2013-05-09 23:01:37
【问题描述】:
如何从AngularUI 的UI Bootstrap 指令中捕获“更新程序”事件?
我已经定义了我的 HTML:
<input type="text" pattern="[0-9]*" class="span6" placeholder="8675309" ng-model="empid" typeahead="entry for entry in httpEmpIdSearch($viewValue, 8)">
...和我的相关功能:
$scope.httpEmpIdSearch = function(query, limit)
{
return $http.get(
'/visitorLog/api/v1/employee/?limit=' + limit + '&empid__startswith=' + query
).then(function(response)
{
output = [];
angular.forEach(response.data.objects, function(value, key) {
this.push(value.bems.toString());
}, output);
return output;
});
}
当用户单击弹出窗口中的 ID 时,我想采取其他操作(自动填写表单)。如果是原始 Bootstrap,我会使用“更新程序”:
$('#sampleElement').typeahead({
minLength: 3,
source: function (query, process)
{
// get the data
},
updater: function (item)
{
// user clicked on an item, do something more!
},
});
我尝试过各种监听器,例如:
$scope.$on('typeahead-updated', function(event)
{ ... }
但我没有办法让我捕捉到这样的事件。选择预输入选项后,我是否可以采取其他措施?
【问题讨论】:
标签: angularjs angular-ui angular-ui-bootstrap