blob: a8cda33c6648f2b4485c2705c28c7cfa2873e29b [file] [log] [blame]
Simon Huntd7c203c2014-12-09 16:51:49 -08001<!DOCTYPE html>
2<html ng-app="notesApp">
3<head>
4 <title>Notes App</title>
5 <script src="../../tp/angular.js"></script>
6</head>
7<body ng-controller="MainCtrl as ctrl">
8
9 <div>
10 <select ng-model="ctrl.selectedCountryId"
11 ng-options="c.id as c.label for c in ctrl.countries">
12 </select>
13 Selected Country ID: {{ctrl.selectedCountryId}}
14 </div>
15
16 <div>
17 <select ng-model="ctrl.selectedCountry"
18 ng-options="c.label for c in ctrl.countries track by c.id">
19 </select>
20 Selected Country: {{ctrl.selectedCountry}}
21 </div>
22
23 <script type="text/javascript">
24 angular.module('notesApp', [])
25 .controller('MainCtrl', [function () {
26 var self = this;
27
28 self.countries = [
29 {label: 'UK', id: 1},
30 {label: 'USA', id: 2},
31 {label: 'France', id: 3},
32 {label: 'Italy', id: 4}
33 ];
34 var first = self.countries[0];
35 self.selectedCountryId = first.id;
36 self.selectedCountry = first;
37 }]);
38 </script>
39
40</body>
41</html>