2
<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>

This is my sample code, I want to get the form data (input field value and ui-select's selected value) on click of submit button, but I'm able to get input value in my controller but not ui-select's selected value in my controller.

So How can I achieve this?

Ashwath S H
  • 481
  • 1
  • 4
  • 13

1 Answers1

2

the ui-select selected value should be the ng-model="select.states" which can be accessed in your controller using

$scope.select.states
Lunny
  • 852
  • 1
  • 10
  • 23
  • If I write $select.selected.state in my ui-select-match it is working correctly, but if I change it to $select.select.states it is not working for me... Can you give me a working plunker or fiddle if possible? – Ashwath S H May 02 '16 at 16:42
  • the problem was this http://stackoverflow.com/questions/25937098/ng-model-is-not-getting-changed-in-ui-select – Lunny May 02 '16 at 17:37