Set array value to Dropdown using Angularjs
Asked Answered
L

2

5

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.

Legend answered 29/1, 2014 at 8:53 Comment(0)
K
11

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/

Kurtz answered 29/1, 2014 at 9:3 Comment(0)
C
4

Read and follow ng-select directive

Conversazione answered 29/1, 2014 at 8:59 Comment(2)
+1. @Vinod, just read the docs once and you will know how to do this.Birdcage
The moment I clicked the link, "The page you requested does not exist. Perhaps you were looking for something else..."Coracorabel

© 2022 - 2024 — McMap. All rights reserved.