Evi*_*key 4 angularjs angular-ui angular-ui-bootstrap
如何从AngularUI的UI Bootstrap指令中捕获"updater"事件?
我已经定义了我的HTML:
<input type="text" pattern="[0-9]*" class="span6" placeholder="8675309" ng-model="empid" typeahead="entry for entry in httpEmpIdSearch($viewValue, 8)">
Run Code Online (Sandbox Code Playgroud)
......和我的相关功能:
$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;
});
}
Run Code Online (Sandbox Code Playgroud)
当用户点击弹出窗口中的ID时,我想采取其他操作(自动填充表单).如果原始Bootstrap我会使用"更新程序":
$('#sampleElement').typeahead({
minLength: 3,
source: function (query, process)
{
// get the data
},
updater: function (item)
{
// user clicked on an item, do something more!
},
});
Run Code Online (Sandbox Code Playgroud)
我尝试了各种各样的听众:
$scope.$on('typeahead-updated', function(event)
{ ... }
Run Code Online (Sandbox Code Playgroud)
但是我没办法让我抓住这样的事件.有一些方法,一旦选择了预先输入选项,我可以采取额外的行动吗?
此外,在ui-bootstrap库的0.4.0版本中,typeahead-on-select现在支持该指令.这应该提供您想要的活动.
请参阅:https: //github.com/angular-ui/bootstrap/commit/91ac17c9ed691a99647b66b3f464e3585398be19
| 归档时间: |
|
| 查看次数: |
2174 次 |
| 最近记录: |