Ng-Options-1

 

In this example ng-options directive generate list of students using array of object "students".The selected student will show in pre element because selected student name bound to the name variable with ng-model directive.

 
 
 
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Welcome to LearnKode - A code learning platform</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> </head> <body ng-app> <div ng-init="students=[{name:'Herry'},{name:'John'},{name:'Peter'}]"> Students: <select ng-model="name" ng-options="student.name as student.name for student in students"></select> <pre>Student: {{name}}</pre> </div> </body> </html>
Output