0
<select ng-model="list">
<option value="1">first</option>
<option value="2">next</option>
</select>

How to get selected option using angularjs? Most of the case I see they use ng-repeat but how to get selected option when I didn't use ng-repeat?

I console.log($scope.list) I got undefined.

Elton Jamie
  • 586
  • 6
  • 17

2 Answers2

0

Here is an example from the Angular Documentation: Plunker

It shows how it is done.

<select ng-model="model.id" convert-to-number>
  <option value="0">Zero</option>
  <option value="1">One</option>
  <option value="2">Two</option>
</select>

Link Updated!

Stefan Dimov
  • 581
  • 3
  • 11
0

You can use ng-options.

See the the plunker

<select ng-model="model" ng-options="item.value as item.display for item in someOptions">

$scope.someOptions = [{display: 'one', value: 1},{display: 'two', value: 2} ,{display:'three', value:3}]
Shai M.
  • 1,284
  • 4
  • 17
  • 30