繁体   English   中英

我正在使用 angular ui-select 进行下拉。 如何在我的控制器中获取选定的值?

[英]I am using angular ui-select for drop down. How can I get the selected value in my controller?

<form name="addForm" novalidate>
<input type="text" name="userName" ng-model="add.userName" placeholder="Enter Name" required>
<ui-select ng-model="select.states" required>
    <ui-select-match placeholder="{{'body.stateAddrPH' | i18n}}">{{$select.selected.state}}</ui-select-match>
    <ui-select-choices repeat="states in (listOfStates | filter: $select.search) track by states.state">
        <span ng-bind="states.state"></span>
    </ui-select-choices>
</ui-select>


<button type="submit" ng-click="submitPayment(add)">Submit</button>
</form>

这是我的示例代码,我想在单击提交按钮时获取表单数据(输入字段值和 ui-select 的选定值),但我能够在控制器中获取输入值,但无法在 ui-select 中获取选定值我的控制器。

那么我怎样才能做到这一点?

ui-select 选择的值应该是 ng-model="select.states" 可以在您的控制器中使用

$scope.select.states

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM