Select property as computed label
Description
The following code shows how to select property as computed label.
Example
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
<script>
var app = angular.module('myApp', []);
<!-- w w w. j a v a 2s . com-->
app.controller('MainCtrl', function($scope) {
$scope.users = [
{ firstName: 'J', lastName: 'J', email: 'j@example.com', sex:"Female"},
{ firstName: 'A', lastName: 'A', email: 'a@example.com', sex:"Female"},
{ firstName: 'S', lastName: 'S', email: 's@example.com', sex:"Male"},
{ firstName: 'K', lastName: 'K', email: 'k@example.com', sex:"Male"}
];
$scope.getFullName = function(user) {
return user.firstName + ' ' + user.lastName;
};
});
</script>
</head>
<body ng-controller="MainCtrl">
<select ng-model="chosenUserEmail" ng-options="user.email as getFullName(user) for user in users"></select>
Selected User's Email: {{ chosenUserEmail }}
</body>
</html>