<html ng-app="notesApp"> <head><title>Notes App</title></head> <body ng-controller="MainCtrl as ctrl"> <div> <select ng-model="ctrl.selectedCountryId" ng-options="c.id as c.label for c in ctrl.countries"> </select> Selected Country ID : {{ctrl.selectedCountryId}} </div> <div> <select ng-model="ctrl.selectedCountry" ng-options="c.label for c in ctrl.countries"> </select> Selected Country : {{ctrl.selectedCountry}} <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.js"> </script> <script type="text/javascript"> angular.module('notesApp', []) .controller('MainCtrl', [function() { this.countries = [ {label: 'USA', id: 1}, {label: 'India', id: 2}, {label: 'Other', id: 3} ]; }]); </script> </body> </html>
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more