Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set array value to Dropdown using Angularjs

I am newbie to Angularjs. Here is my scenario.

I have an array of

numbers = ['1','2','3'];

And also have a

<select id="fileNumber" ng-model="files"></select>

How Can I add the values of array to the dropdown list fileNumber

I tried,

ng-options="numbers"

Can anyone say how to include array value to dropdown list.

like image 949
Hulk1991 Avatar asked Jan 29 '14 08:01

Hulk1991


2 Answers

Here's an example for working with select and adding values to array:

Update:

  <select ng-model='selectedNumber'  ng-options='number for number in numbers'></select>
<button ng-click="add()">add</button>

Live example: http://jsfiddle.net/choroshin/MTfRD/643/

like image 181
Alex Choroshin Avatar answered Sep 26 '22 17:09

Alex Choroshin


Read and follow ng-select directive

like image 37
RaviH Avatar answered Sep 23 '22 17:09

RaviH