我无法访问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"}
]发布于 2017-10-19 14:50:58
检查他们的'Object as source‘example
你需要绑定它来重复,如下所示:
<ui-select-choices repeat="item.type as item in optionTypes">发布于 2017-10-19 14:58:49
在这里,我认为没有必要通过查看您的dropwon集合来使用ng-bind-html。不过,如果需要的话,请确保在控制器$scope中有trustAsHtml函数,然后使用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>https://stackoverflow.com/questions/46824010
复制相似问题