The AngularJS provides many advanced features to drop-down list.
We can get the data from the object or an array to the drop-down list but we should use ng-options instead of option.
We also use repeat directive for make the drop-down list.
We can filter the collection of data, Angular JS supports sorting.
Syntax for Select Box in AngularJS:
Sample code for Select Box in AngularJS:
Data:
Set of data has been used in our AngularJS Application.
HTML:
Viewable HTML contents in AngularJS Application.
Logic:
Controller logic for the AngularJS application.
Code Explanation for select box in AngularJS:
The ng-controller is a directive to control the AngularJS Application.
The ng-repeat directive is used to create an options list for the select box from the technology array and that will be bind by {{ x }}.
The ng-options directive is used to create an options list for drop-down list from the technology array and that will be automatically bind in the select box.
“x for x in technology” is used to get each technology and bind to options in the select box.
The “selectCtrl” used to create the controller for the Application with $scope object argument.
The $scope.technology is an array that has list of technology.
Sample Output for select box in AngularJS:
The ng-repeat used create the list of options in the drop-down list.
The ng-options used create the list of options in the drop-down list, the default value will be blank.