如何在 AngularJS uib-typeahead 中截断结果的长度
How to truncate the length of a result in AngularJS uib-typeahead
我使用 Angular UI Bootstrap typeahead 如下:
<input type="text" ng-model="selectedUser"
uib-typeahead="user as user.Name for user in allUsers | filter:$viewValue | limitTo:8"/>
我希望截断长结果的值,以免下拉列表溢出。在其他文本控件中,我可以使用 | trimValue:20
,但这似乎并没有在 typeahead 中实现。
有效:
<input type="text" ng-model="selectedUser"
uib-typeahead="user as user.Name | trimValue:20 for user in allUsers | filter:$viewValue | limitTo:8"/>
什么不起作用:
<input type="text" ng-model="selectedUser"
uib-typeahead="user as user.Name for user in allUsers | filter:$viewValue | limitTo:8 | trimValue:20"/>
我使用 Angular UI Bootstrap typeahead 如下:
<input type="text" ng-model="selectedUser"
uib-typeahead="user as user.Name for user in allUsers | filter:$viewValue | limitTo:8"/>
我希望截断长结果的值,以免下拉列表溢出。在其他文本控件中,我可以使用 | trimValue:20
,但这似乎并没有在 typeahead 中实现。
有效:
<input type="text" ng-model="selectedUser"
uib-typeahead="user as user.Name | trimValue:20 for user in allUsers | filter:$viewValue | limitTo:8"/>
什么不起作用:
<input type="text" ng-model="selectedUser"
uib-typeahead="user as user.Name for user in allUsers | filter:$viewValue | limitTo:8 | trimValue:20"/>