我無法訪問UI-Select中選定的下拉值,如何訪問控制器中的選定值?如何訪問UI-SELECT下拉值[AngularJS 1.4.7]
<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"}
]
如何在控制器訪問選擇的值有關係嗎? –
通過ng-model,你會得到整個選定的對象 – jabko87
你有一個工作的笨蛋嗎?我沒有定義,當我console.log(「optionType.selected」) –