Home
Tutorials
Microsoft Technologies Tutorials
Java Programming Tutorials
Web Designing Tutorials
Script Programming Tutorials
Database Programming Tutorials
Mobile Technologies Tutorials
Other Programming Tutorials
Examples
Articles
Tools
News
AngularJS ng-options to Set Default Value Example
Keywords : Angularjs ng options set selected value example, Angularjs use ng-options to set default value with example, Angularjs ng-options to set default value in select box example
Example
<!DOCTYPE html> <html> <head> <title> AngularJs ng-options to Set Default Value to Dropdown List Example </title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script> <script> var app = angular.module('ngoptionsApp', []); app.controller('ngoptionsCtrl', function ($scope) { $scope.arrlist = [{ "userid": 1, "name": "Suresh" }, { "userid": 2, "name": "Rohini" }, { "userid": 3, "name": "Praveen" }]; $scope.userselected = $scope.arrlist[2]; }); </script> </head> <body ng-app="ngoptionsApp" ng-controller="ngoptionsCtrl"> <div> <h3>AngularJs ng-options to Set Default Value</h3> <select name="users" ng-options="user.name for user in arrlist" ng-model="userselected"> <option value="">--Select User--</option> </select><br /><br /> <span>User Name: {{userselected.name}}, UserId: {{userselected.userid}}</span> </div> </body> </html>
Click Here to See Result
Result
Previous
Next