具有对象文字结构的Angular UI-Bootstrap Typeahead

时间:2015-06-09 18:51:02

标签: angularjs angular-ui-bootstrap

是否可以将Angular UI-Bootstrap Typeahead与以下数据一起使用?此数据表示wordpress分类,格式为term_id:term_name

$scope.domainFields = {
    "304": "Administration et secr\u00e9tariat",
    "305": "Arts, m\u00e9dias et divertissement",
    "306": "Assurance",
    "307": "Comptabilit\u00e9 et finance"
    //...
};

查看:

我正在使用Angular-xeditable typeahead,它实现了Angular-ui typeahead。

currentUser.field包含当前的term_id,如何在e-typeahead中循环遍历domainFields对象并显示与term_id关联的当前term_name?

<a href="#"
   editable-text="currentUser.field"
   e-typeahead="
   term_id as term_name for field in domainFields
   | filter:$viewValue 
   | limitTo:8">
{{ domainFields[currentUser.field] || 'empty' }}
</a>

1 个答案:

答案 0 :(得分:0)

e-typeahead

中指定重复数组时,需要在对象中使用(键,值)

<强>标记

<a href="#"
   editable-text="currentUser.field"
   e-typeahead="
   term_id as term_name for (term_id, term_name) in domainFields
   | filter:$viewValue 
   | limitTo:8">
{{ domainFields[currentUser.field] || 'empty' }}
</a>