引导超前指令对输入字段不起作用
bootstrap typeahead directive not working on input field
var app = angular.module('plunker', ['ui.bootstrap']);
app.controller('MainCtrl', function($scope) {
$scope.FDLAccountOther = [{
"fdlAccountId": 300,
"fdlAccountName": "IS00698000",
"fdlAccountDesc": "PT Rebates -To Trading Desks on selling concessions paid to IFG",
"fdlAccountType": "R",
"setId": "FDL01",
"isDefault": null,
"balanceForward": null,
"bsIndicator": null,
"status": "Active"
}, {
"fdlAccountId": 301,
"fdlAccountName": "IS00699000",
"fdlAccountDesc": "PT Rebates -To Trading Desks on selling concessions paid to IIG",
"fdlAccountType": "R",
"setId": "FDL01",
"isDefault": null,
"balanceForward": null,
"bsIndicator": null,
"status": "Active"
}]
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0/angular.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/1.2.1/ui-bootstrap-tpls.js"></script>
<!DOCTYPE html>
<html ng-app="plunker">
<div class="input-group" ng-controller="MainCtrl">
<input type="text"
class="form-control"
ng-model="formData_TransGrid.fdlAcctNameOther"
placeholder="Enter FDL Account"
uib-typeahead="item.fdlAccountName as item.fdlAccountName for item in FDLAccountOther | filter:$viewValue|limitTo:3" />
<span class="input-group-btn">
<button class="btn btn-success ebtn"
type="button"
data-toggle="modal"
data-target="#FDLAccountLookUp">
Find FDL
</button>
</span>
</div>
</html>
实际上还有更多的记录,但是TypeAhead建议似乎不起作用,有什么帮助吗?
更新
在 TypeAhead 指令前面添加 UIB 已经解决了这个问题。 感谢您的帮助
更新
在 TypeAhead 指令前面添加 UIB 已经解决了这个问题。 感谢您的帮助
您的预键入逻辑都正常工作,但您需要更新脚本模板中的一些内容才能使其正常工作:
- 正如您将
typeahead
更新为uib-typeahead
一样,您需要将typeaheadHighlight:query
更新为uibTypeaheadHighlight:query
- 您需要使用
ng-bind-html
属性而不是bind-html-unsafe
- 该脚本不知道您的预选配置中的
item
,因此您需要使用match.model
这导致以下...
<script type="text/ng-template" id="/tpl.html">
<a><div>
<span style="display:block;" class="registration" ng-bind-html="match.model.fdlAccountName | uibTypeaheadHighlight:query"></span>
<span ng-bind-html="match.model.fdlAccountDesc | uibTypeaheadHighlight:query"></span> ·
<span ng-bind-html="match.model.status | uibTypeaheadHighlight:query"></span>
</div></a>
</script>
以下是完整的代码片段:
var app = angular.module('plunker', ['ui.bootstrap']);
app.controller('MainCtrl', function($scope) {
$scope.FDLAccountOther = [{
"fdlAccountId": 300,
"fdlAccountName": "IS00698000",
"fdlAccountDesc": "PT Rebates -To Trading Desks on selling concessions paid to IFG",
"fdlAccountType": "R",
"setId": "FDL01",
"isDefault": null,
"balanceForward": null,
"bsIndicator": null,
"status": "Active"
}, {
"fdlAccountId": 301,
"fdlAccountName": "IS00699000",
"fdlAccountDesc": "PT Rebates -To Trading Desks on selling concessions paid to IIG",
"fdlAccountType": "R",
"setId": "FDL01",
"isDefault": null,
"balanceForward": null,
"bsIndicator": null,
"status": "Active"
}]
});
<!DOCTYPE html>
<html ng-app="plunker">
<head>
<link data-require="bootstrap-css@*" data-semver="3.3.6" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.css" />
<script data-require="angular.js@1.5.0" data-semver="1.5.0" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js"></script>
<script data-require="ui-bootstrap@1.1.1" data-semver="1.1.1" src="https://cdn.rawgit.com/angular-ui/bootstrap/gh-pages/ui-bootstrap-1.1.1.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/1.2.1/ui-bootstrap-tpls.js"></script>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
<script type="text/ng-template" id="/tpl.html">
<a><div>
<span style="display:block;" class="registration" ng-bind-html="match.model.fdlAccountName | uibTypeaheadHighlight:query"></span>
<span ng-bind-html="match.model.fdlAccountDesc | uibTypeaheadHighlight:query"></span> ·
<span ng-bind-html="match.model.status | uibTypeaheadHighlight:query"></span>
</div></a>
</script>
</head>
<div class="input-group" ng-controller="MainCtrl">
<input type="text"
class="form-control"
ng-model="formData_TransGrid.fdlAcctNameOther"
placeholder="Enter FDL Account"
uib-typeahead="item.fdlAccountName as item.fdlAccountName for item in FDLAccountOther | filter:$viewValue|limitTo:3"
typeahead-template-url="/tpl.html" />
<span class="input-group-btn">
<button class="btn btn-success ebtn"
type="button"
data-toggle="modal"
data-target="#FDLAccountLookUp">
Find FDL
</button>
</span>
</div>
</html>
相关文章:
- 将输入字段中的文本提交到我的数据库,同时将其添加到我的列表中
- 而循环只设置php中输入字段中的第一个值
- 在输入字段中将最小金额设置为
- 如何在输入字段中的按钮的帮助下打开日历,该字段的类型为“=”;日期”;
- 如何在HTML输入字段中添加不可删除的后缀
- 互斥单选按钮和相应的输入字段
- 在IE9中的输入字段中输入焦点最近按钮
- 选中单选框时将属性添加到输入字段
- 当设置addFromAutocompleteOnly时,剩余文本将保留在输入字段中
- 我如何在数字插入中使用逗号,这样它就不会'不要破坏我的输入字段
- 在输入字段上有两个函数调用,一个在Blur上,一个不在Angular中
- 输入字段将't获取更新的值
- 如何选择多个输入字段并删除所需的属性
- 输入字段,只接受0到12之间的数字
- 单击鼠标,用MySQL数据填充html表单输入字段
- 使用jquery将输入字段转换为文本
- Model中的Typeahead返回空值以形成输入字段
- 如何从查询字符串中的输入字段发回文本
- 如何验证日期、月份和日期的3个独立输入字段;年使用jquery或javascript
- 将值传递给jquery创建的输入字段