AngularJS Select Boxes
Select Boxes
AngularJS allows us to create a drop-down list. We can insert options in it by using the ng-options directive. We can also use ng-repeat for inserting items in the select box but ng-options is specifically designed for this purpose.
ng-repeat Directive:-
The ng-repeat directive is used to repeat a set of HTML a given number of times. The set of HTML will be repeated once per item in a collection. The collection must be an array or an object. If the collection is in the form of objects, then ng-repeat is best for making an HTML table.
Syntax:-
< element ng-repeat="expression" >< /element >
Further Explanation:-
Value | Description |
---|---|
expression |
An expression that specifies how to loop the collection.
|
ng-options Directive:-
The ng-options directive is used to fill a select element with options. The ng-options directive uses an array to fill the dropdown list. It is better than ng-repeat as it is more flexible.
Syntax:-
< select ng-options="array expression" >< /select >
Further Explanation:-
Value | Description |
---|---|
expression | Legal expressions:
|