2

I have following:

<div>
<select multiple>
    <option ng-model="xss" ng-selected="u.selected" ng-repeat="u in xs" value="{{u.value}}">
        {{u.value}}
    </option>
</select>

$scope.xss;
$scope.xs = [
    { id: 1, value: 'value 1', selected: false },
    { id: 2, value: 'value 2', selected: false },
    { id: 3, value: 'value 3', selected: false }
];

The select work fine, however the selected values is not bound to xss. How do you get selected items from a multiple select throug angular?

1 Answer 1

5

You should have the ng-model at the <select> statement instead of options as below,

<select multiple ng-model="xss" >
    <option ng-selected="u.selected" ng-repeat="u in xs" value="{{u.value}}">
      {{u.value}}
    </option>
  </select>

LIVE DEMO

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.