0

After debugging it seems that the status object is getting bound to my model. But I need to bind the string to my model.

$scope.Statuses = [
    {name:'Not Started', value: 'Not Started'},
    {name:'In Progress', value: 'In Progress'},
    {name:'Completed', value: 'Completed'}
];

<select class="form-control" ng-model="counterMeasure.Status" ng-options="status.name for status in Statuses"></select>
2
  • Which string you need to bind? Then you need select as label for value in array Commented Mar 12, 2015 at 9:50
  • I thought it would automatically take the status.value, When I select a status in the list I want my counterMeasure.Status == status.value Commented Mar 12, 2015 at 9:53

1 Answer 1

1

You need to use following ngOptions syntax

select as label for value in array

Change your code to

ng-options="status.value as status.name for status in Statuses"
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.