डाउनलोड पी.डी.एफ. ई-बुक्स
AJS - Directives ng-option

ng-options directive ये <select> element के <option> element के list को dynamically bind करने के लिए इस्तेमाल किया जाता है |


Syntax for ng-options Directive in AngularJS

<select ng-options="expression">
</select>

ng-options Attribute's Parameters in AngularJS

expression : यहाँ पर array expression दिया जाता है |


Example for ng-options Directive using String in AngularJS

Source Code :
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
</head>
<body>

<div ng-app="">

<div ng-init="fruits = ['Mango', 'Pineapple', 'Banana']">
<select ng-model="items" ng-options="ele for ele in fruits"></select>
<p>Selected Option : {{items}}</p>
</div>

</div>

</body>  
</html>
Output :

Selected Option : {{items}}


Example for Add Option items using ng-repeat Directive

Source Code :
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
</head>
<body>

<div ng-app="">

<div ng-init="fruits = ['Mango', 'Pineapple', 'Banana']">
<select>
<option ng-repeat="f in fruits">{{f}}</option>
</select>
</div>

</div>

</body>  
</html>
Output :