通过typeahead-on-select发送选定的预先输入选项

时间:2016-07-26 09:10:31

标签: javascript jquery angularjs angular-bootstrap angularjs-bootstrap

<input type="text"
       class="topic_select"
       id="selectTopic"
       ng-model="topicsPopulate"
       uib-typeahead="topic.name for topic in topics|filter:$viewValue"
       uib-typeahead-show-hint="true"
       uib-typeahead-min-length="1"
       typeahead-on-select="TopicChanged(topicsPopulate)" />

我实际上想要发送我选择的主题(带有许多变量的json对象),而不是topicsPopulate中存储的字符串(主题名称)。 主题是一个主题数组,主题如下:

{
    id: "12967",
    name: "ABCD",
    description: "ABCD"
}

1 个答案:

答案 0 :(得分:1)

uib-typehead遵循与Angular ng-options相同的语法。所以只需改变你的uib-typehead

uib-typeahead="topic as topic.name for topic in topics|filter:$viewValue"

请查看Plunker