http://plnkr.co/edit/BsnSvXlSASPm6EAY1brK?p=preview
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
$scope.options = [
{
name: 'Something Cool',
value: 'something-cool-value'
},
{
name: 'Something Else',
value: 'something-else-value'
}
];
$scope.selectedOption = $scope.options[0];
});
<!DOCTYPE html>
<html ng-app="plunker">
<head>
<meta charset="utf-8" />
<title>AngularJS Plunker</title>
<script>document.write('<base href="' + document.location + '" />');</script>
<link rel="stylesheet" href="style.css" />
<script data-require="angular.js@1.0.x" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.js" data-semver="1.0.7"></script>
<script src="app.js"></script>
</head>
<body ng-controller="MainCtrl">
<select
ng-model="selectedOption"
ng-options="option.name for option in options">
</select>
{{ selectedOption.value }}
</body>
</html>
No comments:
Post a Comment