限制角UI,引导键盘缓冲,以特定对象财产 [英] Limit Angular UI-Bootstrap Typeahead to specific object property

查看:106
本文介绍了限制角UI,引导键盘缓冲,以特定对象财产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下 UI-引导 预输入伟大的工作:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆