通过 typeahead-on-select 发送 selected typeahead 选项

Send selected typeahead option through typeahead-on-select

<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 中的字符串(主题名称)。 Topics是一个主题数组,一个主题是这样的,

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

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

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

请看Plunker.