限制角UI,引导键盘缓冲,以特定对象财产 [英] Limit Angular UI-Bootstrap Typeahead to specific object property
问题描述
I have the following Angular UI-Bootstrap typeahead working great:
<input class="span2" type="text" ng-model="selectedStuff" typeahead="stuff as stuff.name for stuff in stuffs | filter:$viewValue"/>
不过,它几乎工作的太的伟大。我能够显示<$ C $ C> stuffs.name 为预输入
键,选择完整的<$ C $的目的C>的东西对象的东西
。问题是,我的 $ viewValue
是匹配的所有属性的的东西
,而不是仅仅在 stuff.name
。我试着加入。名称
到预输入
不同的地方,没有运气。有没有办法显示一个简单的方法和匹配只有。名称
,但仍返回整个对象?
Though, it's almost working too great. I'm able to display the stuffs.name
for the purposes of the typeahead
AND select the full stuff
object in stuffs
. The problem is that my $viewValue
is matching all of the properties in stuff
instead of just the stuff.name
. I've tried adding the .name
to various places in the typeahead
with no luck. Is there a straightforward way to display and match only the .name
but still return the entire object?
推荐答案
从 HTTP的预输入指令://角UI .github.io /引导/ 回购是建立很好地适应现有AngularJS生态系统。这意味着,该指令尝试重新使用尽可能多的AngularJS已经使用的语法,过滤器和指令。
The typeahead directive from the http://angular-ui.github.io/bootstrap/ repo was build to well fit into existing AngularJS ecosystem. This means that this directive tries to re-use as much as possible of syntax, filters and directives already used in AngularJS.
回到你的问题 - 本身是由这里所描述的角的滤芯过滤进行过滤:<一href=\"http://docs.angularjs.org/api/ng.filter:filter\">http://docs.angularjs.org/api/ng.filter:filter上面提到的过滤器的语法非常灵活,搜索限制在选定的一组属性:
Back to your question - the filtering itself is done by the Angular's filter filter described here: http://docs.angularjs.org/api/ng.filter:filter The mentioned filter's syntax is flexible enough to limit searches to a selected set of properties:
预输入=的东西,stuff.name在东西的东西|过滤器:{名:$ viewValue}
请注意:过滤器:{名:$ viewValue}
工作花掉这里:<一href=\"http://plnkr.co/edit/o1qWKq8LSmbbmVaYkOvb?p=$p$pview\">http://plnkr.co/edit/o1qWKq8LSmbbmVaYkOvb?p=$p$pview
这篇关于限制角UI,引导键盘缓冲,以特定对象财产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!