javascript - 如何访问 UI-SELECT 下拉值 [AngularJS 1.4.7]

标签 javascript angularjs ui-select angular-ui-select

我无法在 UI-Select 中访问选定的下拉值,如何在 Controller 中访问选定的值?

<ui-select name="optionType" ng-model="optionType.selected" theme="bootstrap"  append-to-body="true" reset-search-input="true">
  <ui-select-match placeholder="Option">
    <span ng-bind-html="ctrl.trustAsHtml($select.selected.type)"></span>
  </ui-select-match>
  <ui-select-choices repeat="option in optionTypes | filter: $select.search" position="down">
    <span ng-bind-html="ctrl.trustAsHtml(option.type) | highlight: $select.search"></span>
  </ui-select-choices>
</ui-select>

Controller :

$scope.optionType = {};

$scope.optionTypes =
  [
    {type: "Risk Reversal"},
    {type: "Straddle"},
    {type: "Strangle"},
    {type: "Spread"},
    {type: "VANILLA"}
  ]

最佳答案

检查他们的“对象作为源”example

你需要像这样绑定(bind)它来重复:

<ui-select-choices repeat="item.type as item in optionTypes">

关于javascript - 如何访问 UI-SELECT 下拉值 [AngularJS 1.4.7],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46824010/

相关文章:

angularjs - 使用 md-select,传递 ng-repeat 项目的整个对象,而不仅仅是一个字符串

javascript - 在没有 Controller 的情况下,ng-init 真的是一种糟糕的设置变量的方法吗

javascript - Angular ui-select,忽略选择中的空项目

javascript - 如何在 AngularJS 应用程序中使用两个 hashPrefix?

javascript - 如何使用jQuery隐藏子页面?

javascript - Window 对象是否有获取/设置键的方法?

javascript - 滑入/滑出目标元素的指令

javascript - 将 ASP.NET MVC 模型分配给 AngularJS 范围

javascript - 访问node.js中另一个类的构造函数值

javascript - Angular ui-select 未在下拉列表中加载大列表