我无法在UI-Select中访问所选的下拉列表值,如何访问控制器中的选定值?
<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>
控制器:
$scope.optionType = {};
$scope.optionTypes =
[
{type: "Risk Reversal"},
{type: "Straddle"},
{type: "Strangle"},
{type: "Spread"},
{type: "VANILLA"}
]
答案 0 :(得分:1)
答案 1 :(得分:0)
通过查看您的dropwon集合,我看不出需要使用ng-bind-html
。如果您需要它,请确保您在控制器trustAsHtml
内有$scope
功能,然后使用trustAsHtml(selected.type)
代替ctrl.trustAsHtml(selected.type)
。
没有ng-bind-html
<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="$select.selected.type"></span>
</ui-select-match>
<ui-select-choices repeat="option in optionTypes | filter: $select.search" position="down">
<span ng-bind="option.type | highlight: $select.search"></span>
</ui-select-choices>
</ui-select>